PDA

View Full Version : Solved: subscript out of range



av8tordude
02-03-2013, 09:42 AM
I'm trying to check if a cell is empty. When I select the sheet from the combox, I get an error from the code below. Any ideas?

To check cell A1 is empty on a specific sheet, the combo box (cboYear) to select the sheet name. The combo box is on a userform.

Msgbox Sheets(cboYear).Range("A1") = ""

HaHoBe
02-03-2013, 09:55 AM
Hi, av8tordude,

maybe
MsgBox Len(Sheets(cboYear.Value).Range("A1").Value) or
With Sheets(cboYear.Value).Range("A1")
If Len(.Value) = 0 Then
MsgBox .Parent.Name & " cell '" & .Address(0, 0) & "' is empty"
End If
End With Ciao,
Holger

snb
02-03-2013, 10:01 AM
This suffices:


Msgbox Sheets(cboYear.Value).Range("A1") = ""

av8tordude
02-03-2013, 10:04 AM
Thank you both for you help:friends:

av8tordude
02-03-2013, 10:58 AM
Thank you both for your help:friends: