Checking For Empty Cells

Drip_Drip

Board Regular
Joined
Oct 15, 2004
Messages
54
I've setup a userform for inputting data which to my amazement works.

The problem is that the data is entered in the rows based on the first empty cell in column B.

How can I setup a loop to check for empty cells when the userform is opening and place an 'X' in the empty ones? This should then mean that all new records are automatically placed after the last record entered.

I've tried using bits of code from the forum (without any success) but don't understand how they work.

Thanks
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Call this code from your Userform_Initilaize code, I think this is what you wanted: It will need to be changed if you want more that 20 rows, it looks through rows 1-20 in Column B, if you need more rows, change the 20 to the number of rows you need:


Code:
Sub Loop1()
'1-20 refers to rows
    For i = 1 To 20
    'the 2 is the column looping through (B)or: 2
    'If cells are empty,  ("")
        If Cells(i, 2).Value = "" Then
       'then place an (x) in the empty cells
            Cells(i, 2).Value = "X"
        End If
    Next i
End Sub
 
Upvote 0
Thanks, that's given me an idea. The number of rows will vary day by day but have got around that.
 
Upvote 0

Forum statistics

Threads
1,221,672
Messages
6,161,198
Members
451,688
Latest member
Gregs44132

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