Need to find rows with 2 or more contiguous cells with zeros, but also with data on each side.

scubatke

New Member
Joined
Mar 17, 2018
Messages
10
I've found a lot of help from the site previously but this is the first time I've actually asked a question. So thanks for the past help and hopefully thanks in advance for answering this question.

I have several thousand rows of data (24 columns wide) and I need to flag the rows that have two or more contiguous cells with zeros in them, but only if the cells on each side have data in them.

For example:
11000032

<tbody>
</tbody>

I don't need to flag each instance, just yes/no if it occurs in a row.

Is this even possible?
 
Once again, I appreciate your efforts Rick. Using the second method, I'm still not quite there.

I'm trying to post some data but I keep getting a warning from Chrome about suspicious code; I can't even preview the post when it contains the data.

There is some good news...I'm not seeing any false positives.


Sorry, forgot about that. Try this version...
Code:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Function NumZeroNum(Rng As Range) As String
  NumZeroNum = Array("No", "Yes")(-(Join(Application.Index(Rng.Value, 1, 0)) Like "*[1-9]* 0 0 *[1-9]"))
End Function[/TD]
[/TR]
</tbody>[/TABLE]

Edit Note: If you are looking for a formula solution and you are using Excel 365, make sure you look at what Peter posted in Message #7 .
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Once again, I appreciate your efforts Rick. Using the second method, I'm still not quite there.
Can you describe (and give an example) in what way you are "still not quite there"? What is my code doing or not doing that you expect it to do?
 
Upvote 0
I tried posting the data as a 'quick reply' instead of 'reply with quote' but it went to moderation.
I don't need your actual data (at least I don't think I do), just a description of what is not happening the way you expect. As for an example, do what you did in your first message.
 
Upvote 0
Thanks Marcelo. My data is in columns AK thru BH. For row 1597 did I set up your formula correctly?

=IF(SUM(IF(FREQUENCY(IF((AL1597:bf1597=0)*(Ak1597:be1597<>0)*(am1597:bg1597=0)+(al1597:bf1597=0)*(ak1597:be1597=0)*(am1597:bg1597<>0),COLUMN(al1597:bf1597)),IF(al1597:bf1597<>0,COLUMN(al1597:bf1597)))>1,1)),"Yes","No")



Another possible solution using formulas
(using the data layout provided by Peter in post 7 above)

Array formula in K2 copied down
=IF(SUM(IF(FREQUENCY(IF((B2:I2=0)*(A2:H2<>0)*(C2:J2=0)+(B2:I2=0)*(A2:H2=0)*(C2:J2<>0),COLUMN(B2:I2)),IF(B2:I2<>0,COLUMN(B2:I2)))>1,1)),"Yes","No")
Ctrl+Shift+Enter

M.
 
Upvote 0
I don't need your actual data (at least I don't think I do), just a description of what is not happening the way you expect. As for an example, do what you did in your first message.
I may have spotted the problem with my UDF. It appears I omitted an asterisk (wildcard) at the end of the pattern. See if this version of my UDF works for you...
Code:
Function NumZeroNum(Rng As Range) As String
  NumZeroNum = Array("No", "Yes")(-(Join(Application.Index(Rng.Value, 1, 0)) Like "*[1-9]* 0 0 *[1-9]*"))
End Function
 
Upvote 0
PERFECT!!!

I have about 700 rows of data that I had manually flagged previously. Your code pointed out several mistakes that I had made (OK...it was more than several...LOL)!

THANKS SO MUCH!!!

I won't ask you to explain every element of the code but are there any good learning resources you can recommend? What terms should I Google (in addition to User Defined Function)?


I may have spotted the problem with my UDF. It appears I omitted an asterisk (wildcard) at the end of the pattern. See if this version of my UDF works for you...
Code:
Function NumZeroNum(Rng As Range) As String
  NumZeroNum = Array("No", "Yes")(-(Join(Application.Index(Rng.Value, 1, 0)) Like "*[1-9]* 0 0 *[1-9]*"))
End Function
 
Upvote 0
Thanks Marcelo. My data is in columns AK thru BH.

You already have a solution with VBA - UDF provided by Rick Rothstein - but if you are interested in a solution with formulas, maybe this new and shorter version...

Data sample in post 10 (data in columns AL thru BG; results in column BH)


AL
AM
AN
AO
AP
AQ
AR
AS
AT
AU
AV
AW
AX
AY
AZ
BA
BB
BC
BD
BE
BF
BG
BH
1
2
822,3​
0​
119,7​
61,9​
31,9​
61,6​
0​
0​
0​
0​
0​
226,7​
0​
0​
0​
0​
93,9​
32,9​
0​
0​
229,4​
0​
Yes​
3
49,9​
0​
0​
0​
0​
0​
0​
386,3​
96,2​
564,4​
1090,3​
598,2​
402,1​
512,2​
866,4​
144,8​
506,4​
0​
267,4​
184,2​
242​
384,3​
Yes​
4
1272,7​
624,2​
904,3​
1247,6​
475,5​
1170,5​
690,8​
1138,5​
1205,9​
786,4​
845,1​
263,5​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
No​
5
1534,2​
1009,9​
1197,1​
1094,6​
1676,7​
684,2​
530,8​
1277,9​
938,3​
1252,6​
1066​
1275​
1754,1​
962,8​
100,5​
140,1​
57,5​
0​
0​
994,8​
479,8​
181,1​
Yes​
6
128,4​
60,9​
124,7​
41,7​
129,4​
104,7​
105​
66,1​
126,8​
126,7​
0​
0​
44,1​
0​
0​
0​
0​
0​
0​
0​
0​
0​
Yes​
7
82,5​
0​
144,2​
0​
0​
0​
0​
0​
0​
0​
0​
0​
72,5​
0​
0​
15,5​
19,5​
0​
0​
0​
0​
0​
Yes​
8
263​
26,3​
210,4​
210,4​
157,8​
263​
210,4​
236,7​
289,3​
289,3​
52,6​
0​
0​
0​
2,6​
0​
0​
0​
0​
7,9​
0​
0​
Yes​
9
55,6​
325,8​
0​
352,9​
0​
0​
0​
39​
90,8​
0​
0​
202,8​
0​
113,7​
96,2​
0​
0​
0​
0​
0​
0​
0​
Yes​
10
0​
90,5​
70,3​
46,1​
155​
0​
46,7​
68,9​
67,2​
153,5​
181,7​
64,8​
0​
23​
0​
0​
85,8​
68,9​
193​
0​
198,5​
0​
Yes​
11
196,5​
17​
0​
0​
0​
0​
0​
0​
16,6​
17​
0​
16,9​
0​
0​
15,4​
0​
0​
9,2​
0​
17,3​
0​
0​
Yes​

<tbody>
</tbody>


Array formula in BH2 copied down
=IF(SUM(IF(FREQUENCY(IF((AM2:BF2=0)*(AL2:BE2<>0)+(AM2:BF2=0)*(AN2:BG2<>0),COLUMN(AM2:BF2)),IF(AM2:BF2<>0,COLUMN(AM2:BF2)))>1,1)),"Yes","No")
Ctrl+Shift+Enter

M.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top