View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Alan[_2_] Alan[_2_] is offline
external usenet poster
 
Posts: 116
Default Macro and range names

I guess I didn't read your question correctly, and took you for a beginner,
thus my simple answer. I apologize. If you were talking about the usage of
shtInpinfo in the line:

If shtInpInfo.Range("valid").Value < 0 Then

should read

If Sheets("shtInpInfo").Range("valid").Value < 0 Then


Regards,

Alan

"Jim Thomlinson" wrote in message
...
I personally avoid that kind of thing. The problem with it is "If
shtInpInfo
is the active sheet ". Why leave it to chance. At some point you are going
to
alter the flow of your program and potentially change which sheet is
active
and whether a named range is global or local. Now this procedure may not
work
any more although it is hard to tell that since it is not always obvious
which sheet is active at any given time and whether a named range is
global
or local... you will never go wrong being more explicit than less...
--
HTH...

Jim Thomlinson


"Alan" wrote:

If shtInpInfo is the active sheet you can use this:

If Range("valid").value < 0 Then
shtInput.[button 17].Visible = False
Beep
End If

If it is not the active sheet, you need to state the sheet name just as
your
did.


"Brad" wrote in message
...
My question is this

Using the VBE I have rename sheetxx to shtInpinfo - Do I need the all
of
the
following code to use the range name "valid"?

If shtInpInfo.Range("valid").value < 0 Then
shtInput.[button 17].Visible = False
Beep
End If