Cell reference in VBA
Excel doesn't like "data" as a named range.
This will work...........
Sub test()
If Range("myname") = "000" Then
MsgBox "hello"
End If
End Sub
Or this construct..............
Set r = Range("myname")
If r.Cells = "000" Then
MsgBox "hello"
End If
Gord Dibben MS Excel MVP
On Sun, 20 Sep 2009 10:22:01 -0700, Tami
wrote:
i have a line of VBA code that asks if cell O1 is "000" then yada yada yada.
It looks like this:
If Cells(1, 15) = "000" Then
But if i insert a column somewhere to the left of column O, my code still
refers to cell O1 but needs to now refer to cell P1.
I've named the cell "data" and i tried
If Cells("data")="000" Then
but that didnt' work.
any other suggestions?
|