Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default passing a variable from sheet to form to another sheet

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default passing a variable from sheet to form to another sheet

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   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default passing a variable from sheet to form to another sheet

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
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
Creating form on sheet 1 and having info move to sheet 2 SHARON Excel Discussion (Misc queries) 4 June 1st 09 05:01 PM
How To make a sheet reference Variable (eq: sum(sheet!D2:H2)) John Linker Excel Discussion (Misc queries) 3 June 16th 08 11:29 PM
Copy my active sheet to a new sheet and open with an input form Brad Withrow Excel Programming 0 April 6th 06 03:56 AM
Passing Variable from Sheet to Userform gti_jobert[_40_] Excel Programming 1 February 27th 06 09:38 AM
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? Daniel[_14_] Excel Programming 1 August 29th 04 01:20 PM


All times are GMT +1. The time now is 05:13 PM.

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

About Us

"It's about Microsoft Excel"