Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro and range names
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro and range names
There are 2 different kinds of named ranges; global and sheet specific. If
the named range is sheet specific then you need to have the code as you have written it. If the named range is global then you can get away with just If Range("valid").value < 0 Then That being said I would stick with the code that you have as it should work in both circumstances. When in doubt being more specific with your references will always work out for you. -- HTH... Jim Thomlinson "Brad" wrote: 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro and range names
Thanks for the third time.
"Jim Thomlinson" wrote: There are 2 different kinds of named ranges; global and sheet specific. If the named range is sheet specific then you need to have the code as you have written it. If the named range is global then you can get away with just If Range("valid").value < 0 Then That being said I would stick with the code that you have as it should work in both circumstances. When in doubt being more specific with your references will always work out for you. -- HTH... Jim Thomlinson "Brad" wrote: 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro and range names
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro and range names
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro and range names
shtInpInfo is the code name for the sheet and not the tab name so I stand by
my original code. I have been helping Brad to get away from using Sheets("Tab name"). style code since it can generate errors if the end user modifies the tab name... -- HTH... Jim Thomlinson "Alan" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Reference Range Names in Macro | Excel Discussion (Misc queries) | |||
Rename Several Defined Range Names with Macro | Excel Programming | |||
Using range names in a macro formula | Excel Programming | |||
Macro for Range Names | Excel Programming |