热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Excelvba:逐行查找范围内的布尔值对-Excelvba:Findingpairofbooleanvaluesinrangerowbyrow

ImtryingtosolvearatherbasicquestioninaexcelsheetusingvbabutIcantfindtheanswer..

I'm trying to solve a rather basic question in a excel sheet using vba but I can't find the answer...

我正在尝试使用vba在excel表中解决一个相当基本的问题,但我找不到答案......

I am working on a timetable which is dynamically populated from an other excel sheet with boolean values True or False. The named range is called "A" in excel and contains boolean values True or False. Every column represents a possible start hour. Every row represents a different collage with a starting hour and an end hour. Each row can have NO values (entire row = False = collage is on leave) OR the row can have two values TRUE on different cells in the same row representing start hour and end hour. What I would like to achieve is a to find ROW by ROW for a couple of boolean TRUE. If found the cells between the first and second True should be colored in let's say yelow.

我正在制作一个时间表,该时间表是从其他excel表中动态填充的,其布尔值为True或False。命名范围在excel中称为“A”,包含布尔值True或False。每列代表一个可能的开始时间。每行代表一个不同的拼贴画,包括开始时间和结束时间。每行可以具有NO值(整行= False =拼贴处于休假状态)或者该行可以在表示开始时间和结束时间的同一行中的不同单元格上具有两个值TRUE。我想要实现的是通过ROW找到ROW的几个布尔值TRUE。如果发现第一个和第二个真实之间的单元格应该被标记为黄色。

I am able to loop in a named range finding a specific value but I'm unable to find a pair of TRUE values in a specific row. As a double check I want to be sure that the first an second TRUE MUST be on the same row. So it is impossible to color between 2 cells in a different row.

我能够在命名范围内循环查找特定值,但我无法在特定行中找到一对TRUE值。作为一个双重检查,我想确保第一个第二个TRUE必须在同一行。因此,不可能在不同行中的2个单元格之间进行着色。

See picture :

见图:

Some advice or thought would be greatly appreciated!

一些建议或想法将不胜感激!

1 个解决方案

#1


0  

You can do this with conditional formatting.

您可以使用条件格式执行此操作。

Select the full range and then use the formulas below in conditional formatting.

选择完整范围,然后在条件格式中使用下面的公式。

=COUNTIF($A1:A1,"TRUE")>1 formatted as white

= COUNTIF($ A1:A1,“TRUE”)> 1格式化为白色

=COUNTIF($B1:B1,"TRUE")>0 formatted as yellow

= COUNTIF($ B1:B1,“TRUE”)> 0格式化为黄色

The formulas count the the number of cells with "True" for the specified range.

公式计算指定范围的“True”单元格数。

Conditional Formatting

Another way could be to add 2 columns to the right of your data and use formulas to find the start and finish times and then conditionally format based on the time headings and the 2 new values.

另一种方法是在数据右侧添加2列,并使用公式查找开始和结束时间,然后根据时间标题和2个新值有条件地格式化。


推荐阅读
author-avatar
DiKi造型Alen老师
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有