Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Passing worksheet as an argument

Is there a way to pass a worksheet name as an argument? I want to
hide all of my worksheet tabs and i have created macro buttons to open
the worksheets, but they have to be unhidden first. What I would like
it to do is when I click the button.... unhide the worksheet i want to
open, then show that one... then I would like to take that active
sheet and brand it with oldSheet and then when they go back to main
worksheet tab and click another button, to hide oldSheet and unhide
the one they just clicked on and then show that one. The only way it
seems logical to me is to pass the argument in each macro button, but
it's not working. ANy Ideas as to where I'm going wrong?


p.s. and would I have to make them all public sub to pass the info?

-Marcus

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default Passing worksheet as an argument

Declare the variable that you use for the name of the currently-open sheet as
a public variable: in an area above the first sub, type:
Public MySheet as string

Then when you open a sheet:

let MySheet="EmployeeListing"
Sheets(MySheet).Visible = True

Then in your code when you go to the next sheet:
if len(MySheet)0 then
'if there has not been a sheet open, you need to test for it this way
sheets(MySheet).visible=false
end if
Let MySheet="NextSheet"
sheets(MySheet).visible=true



"Marcusdmc" wrote:

Is there a way to pass a worksheet name as an argument? I want to
hide all of my worksheet tabs and i have created macro buttons to open
the worksheets, but they have to be unhidden first. What I would like
it to do is when I click the button.... unhide the worksheet i want to
open, then show that one... then I would like to take that active
sheet and brand it with oldSheet and then when they go back to main
worksheet tab and click another button, to hide oldSheet and unhide
the one they just clicked on and then show that one. The only way it
seems logical to me is to pass the argument in each macro button, but
it's not working. ANy Ideas as to where I'm going wrong?


p.s. and would I have to make them all public sub to pass the info?

-Marcus


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Passing worksheet as an argument

On Oct 30, 6:27 am, Mike H. wrote:
Declare the variable that you use for the name of the currently-open sheet as
a public variable: in an area above the first sub, type:
Public MySheet as string

Then when you open a sheet:

let MySheet="EmployeeListing"
Sheets(MySheet).Visible = True

Then in your code when you go to the next sheet:
if len(MySheet)0 then
'if there has not been a sheet open, you need to test for it this way
sheets(MySheet).visible=false
end if
Let MySheet="NextSheet"
sheets(MySheet).visible=true



"Marcusdmc" wrote:
Is there a way to pass a worksheet name as an argument? I want to
hide all of my worksheet tabs and i have created macro buttons to open
the worksheets, but they have to be unhidden first. What I would like
it to do is when I click the button.... unhide the worksheet i want to
open, then show that one... then I would like to take that active
sheet and brand it with oldSheet and then when they go back to main
worksheet tab and click another button, to hide oldSheet and unhide
the one they just clicked on and then show that one. The only way it
seems logical to me is to pass the argument in each macro button, but
it's not working. ANy Ideas as to where I'm going wrong?


p.s. and would I have to make them all public sub to pass the info?


-Marcus- Hide quoted text -


- Show quoted text -


Thank you very much for all of your help!!!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default Passing worksheet as an argument

Sure. It took me a minute to figure out what was until I saw when I first
posted. Later....

"Marcusdmc" wrote:

On Oct 30, 6:27 am, Mike H. wrote:
Declare the variable that you use for the name of the currently-open sheet as
a public variable: in an area above the first sub, type:
Public MySheet as string

Then when you open a sheet:

let MySheet="EmployeeListing"
Sheets(MySheet).Visible = True

Then in your code when you go to the next sheet:
if len(MySheet)0 then
'if there has not been a sheet open, you need to test for it this way
sheets(MySheet).visible=false
end if
Let MySheet="NextSheet"
sheets(MySheet).visible=true



"Marcusdmc" wrote:
Is there a way to pass a worksheet name as an argument? I want to
hide all of my worksheet tabs and i have created macro buttons to open
the worksheets, but they have to be unhidden first. What I would like
it to do is when I click the button.... unhide the worksheet i want to
open, then show that one... then I would like to take that active
sheet and brand it with oldSheet and then when they go back to main
worksheet tab and click another button, to hide oldSheet and unhide
the one they just clicked on and then show that one. The only way it
seems logical to me is to pass the argument in each macro button, but
it's not working. ANy Ideas as to where I'm going wrong?


p.s. and would I have to make them all public sub to pass the info?


-Marcus- Hide quoted text -


- Show quoted text -


Thank you very much for all of your help!!!

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
Passing a Control as an Argument Goofy Excel Programming 14 November 1st 06 11:38 AM
Passing a UDF as an argument to a UDF puff Excel Discussion (Misc queries) 3 February 23rd 06 09:46 PM
Passing argument to another Sub Roman Excel Programming 6 February 1st 05 09:17 PM
Passing Worksheet tab as an argument. Kashizzz Excel Programming 4 September 2nd 04 08:37 AM
Passing range as argument Jan Kronsell[_2_] Excel Programming 3 September 3rd 03 12:31 PM


All times are GMT +1. The time now is 07:23 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"