Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reference Range Names in Macro Karin Excel Discussion (Misc queries) 8 August 27th 09 02:32 PM
Rename Several Defined Range Names with Macro ExcelUser777 Excel Programming 2 January 2nd 07 01:51 PM
Using range names in a macro formula melric Excel Programming 8 March 17th 06 07:48 PM
Macro for Range Names SamDev Excel Programming 11 November 23rd 05 03:25 AM


All times are GMT +1. The time now is 06:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"