Loop ignoring blank cells

sulley333

Board Regular
Joined
Apr 29, 2010
Messages
71
Hi!

I have a macros that loops through and gets a list of distinct values from a certain column...I wrote the code not anticipating blanks in my data...now I have come across a time when I need to ignore the blanks if they are there...any help?

Code:
    nrow = 0 'reset nrow for use below
    For r = 2 To datarow 'loops down the data sheet
 
        If wf.CountIf(ws_drill_value2.Range("A1:A1000"), ws_data.Cells(r, ncol).Value) = 0 Then
            nrow = nrow + 1 'counter for a new name
            ws_drill_value2.Cells(nrow, 1).Value = ws_data.Cells(r, ncol).Value
        End If
 
    Next r
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Where would I put that in the loop? I want it to basically skip that cell...is that what you were thinking?

THanks so much for your help!
 
Upvote 0

Forum statistics

Threads
1,226,727
Messages
6,192,686
Members
453,746
Latest member
Bruce at Pubdarts

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