Use VBA to look for consecutive values in a column

djaenike

New Member
Joined
Nov 5, 2017
Messages
16
I am still quite new to VBA and am looking for some help writing an "if statement" that will look through a column of data and find consecutive values (say 60 consecutive cells worth of 0's). I would only like the code to progress If the condition is met (60 cells in a row worth of 0's). I have absolutely no idea where to start.

All suggestions and criticisms welcome!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I think this is beyond a single If statement (I'm sure someone could prove me wrong). Are you looking for a single instance of 60+ consecutive 0's in a column, or are you looking for a count of all consecutive duplicate rows of any value?

I think the first step I would take is to identify the last row in the table. Then, depending on what you want to do with the consecutive values, a For loop to go row by row through your table; comparing cells looking for consecutive values. Might even need a Boolean variable to toggle an If statement if consecutive values are found. A lot of the coding that will go in the loop depends on what is being done with the consecutive occurrences.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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