Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi to all
My worksheet has a button (btnShowList) that, when clicked, opens a form (frmShowList). This form also has a button (btnBuildTeamSheet) that calls a sub (BuildTeamSheet) that adds a new worksheet, formats it, adds formulas, etc. Here's my problem. I need to somehow pass the NAME of the original worksheet to the SUB that builds the new worksheet. I'm just not sure how to do this. Thks anny |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Isn't that sheet the activesheet when the first button is pressed - and I
would assume it is still the activesheet when the macro starts, so sName = Activesheet.Name at the beginning of the macro. Or have a public variable in a general module and set it in btnShowList Private Sub btnShowList_Click() sName = me.name in a general module at the top Public sName as String public variables in a general module have project level scope. -- Regards, Tom Ogilvy "anny" wrote in message ... hi to all My worksheet has a button (btnShowList) that, when clicked, opens a form (frmShowList). This form also has a button (btnBuildTeamSheet) that calls a sub (BuildTeamSheet) that adds a new worksheet, formats it, adds formulas, etc. Here's my problem. I need to somehow pass the NAME of the original worksheet to the SUB that builds the new worksheet. I'm just not sure how to do this. Thks anny |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi anny,
You could try... In your BuildTeamSheet() sub, make this declaration... Dim wksSource As Worksheet then, before adding the new worksheet, add this line... Set wksSource = ActiveSheet to get a reference to the worksheet object. This assumes the subject sheet is active when the user clicks btnBuildTeamSheet. You can now refer to it directly in the BuildTeamSheet() sub as wksSource, and use it like this... wksSource.Range("A1").Value = 'whatever OR With wksSource 'do something End With HTH Regards, Garry |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Creating form on sheet 1 and having info move to sheet 2 | Excel Discussion (Misc queries) | |||
How To make a sheet reference Variable (eq: sum(sheet!D2:H2)) | Excel Discussion (Misc queries) | |||
Copy my active sheet to a new sheet and open with an input form | Excel Programming | |||
Passing Variable from Sheet to Userform | Excel Programming | |||
Is it possible to open the VBA form with a link in a sheet and to pass variable from a cell to the VBA form? | Excel Programming |