PDA

View Full Version : [SOLVED:] How to check if Cells has content or not



Cinema
11-18-2016, 01:54 AM
Hi,

I have written a code but I want to include and If ...Then..Else command.
How can I check if Range("A8:A40") has Content or not. If Range("A8:A40") has Content Then Do Nothing Else ....
Can somebody help me?

Cinema
11-18-2016, 01:55 AM
Sorry it should be: If Range("A8:A40") has no Content then DoNothing

mana
11-18-2016, 07:04 AM
Sub test()
MsgBox WorksheetFunction.CountA(Range("A8:A40"))
End Sub

Cinema
11-18-2016, 07:37 AM
Hi mana,

thank you. I did it like this:

Set rng = wb.Sheets("Sheet1").Range("A8:A40")
If WorksheetFunction.CountA(rng) = 0 Then
...
Else
...
End If