ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing worksheet as an argument (https://www.excelbanter.com/excel-programming/400178-passing-worksheet-argument.html)

Marcusdmc

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


Bob Phillips

Passing worksheet as an argument
 
Sub HandleWS(byref ws as Worksheet)

With ws
'do stuff
End With

End Sub

Sub DoSomething()

Call HandleWS(ws:=Worksheets(1))
'etc.
End Sub

and so on

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Marcusdmc" wrote in message
ups.com...
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





All times are GMT +1. The time now is 09:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com