Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Define worksheet as variable, then call in macro


Hello All,

I want to dim a worksheet name, and then later call it as a variable to
go to in another macro.

e.g.

Dim callworksheetname as worksheets
callworksheetname = bob

Call bobsaddress()
Activate.bob.worksheet

I know the above is wrong, but you can guess what i am getting at

Any help please?

J


--
bugman
------------------------------------------------------------------------
bugman's Profile: http://www.excelforum.com/member.php...o&userid=28999
View this thread: http://www.excelforum.com/showthread...hreadid=487283

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Define worksheet as variable, then call in macro

Hi Bugman,

Try something like:

'==========
Public Sub One()
Dim SH As Worksheet

With ActiveWorkbook
Set SH = .Worksheets(.Worksheets.Count)
End With

Call Two(SH)

End Sub

'------------

Public Sub Two(aSheet As Worksheet)

MsgBox aSheet.Name

End Sub
'<<==========

---
Regards,
Norman


"bugman" wrote in
message ...

Hello All,

I want to dim a worksheet name, and then later call it as a variable to
go to in another macro.

e.g.

Dim callworksheetname as worksheets
callworksheetname = bob

Call bobsaddress()
Activate.bob.worksheet

I know the above is wrong, but you can guess what i am getting at

Any help please?

J


--
bugman
------------------------------------------------------------------------
bugman's Profile:
http://www.excelforum.com/member.php...o&userid=28999
View this thread: http://www.excelforum.com/showthread...hreadid=487283



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Define worksheet as variable, then call in macro

Dim callworksheetname as worksheet
callworksheetname = bob

Call bobsaddress()
worksheet(callworksheetname ).Activate


or do you want to pass the worksheet name to the module?

Call bobsaddress(callworksheetname)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"bugman" wrote in
message ...

Hello All,

I want to dim a worksheet name, and then later call it as a variable to
go to in another macro.

e.g.

Dim callworksheetname as worksheets
callworksheetname = bob

Call bobsaddress()
Activate.bob.worksheet

I know the above is wrong, but you can guess what i am getting at

Any help please?

J


--
bugman
------------------------------------------------------------------------
bugman's Profile:

http://www.excelforum.com/member.php...o&userid=28999
View this thread: http://www.excelforum.com/showthread...hreadid=487283



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
Define Variable Name using VBA GTReferee Excel Discussion (Misc queries) 2 January 21st 09 06:37 PM
How to take the worksheet name as a variable(Label/Define) in a fo Subin Excel Worksheet Functions 2 March 14th 06 12:43 PM
call a macro in another worksheet? George Conard Excel Programming 2 May 16th 05 08:38 PM
How to define variable kishore Excel Programming 3 May 13th 05 10:22 AM
how to call a macro from a worksheet event? lopsided[_3_] Excel Programming 5 December 16th 03 10:28 AM


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

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"