Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default worksheet name store in a variable

Hi guys,
I'm finishing up a macro and need to store the name of the macro in a
variable.

I want the macro to find out what worksheet the user is on, execute the
program which in this case is a webquery (which runs on a specific
worksheet), and return to the worksheet that the user was originally looking
at.

I'm thinking that the best way to do this is to first set a variable to the
name of the active worksheet, execute the program, and lastly to activate the
original worksheet by using the variable that was set in the first operation.

What do you guy think?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default worksheet name store in a variable

Dim wks as Worksheet

set wks = activesheet
'Your Code Here...
wks.Select

--
HTH...

Jim Thomlinson


"Steve P" wrote:

I'm sorry... I need the name of the active WORKSHEET to be stored in a
variable... not the name of the macro. Its late and I've been coding all
day...lol.

"Steve P" wrote:

Hi guys,
I'm finishing up a macro and need to store the name of the macro in a
variable.

I want the macro to find out what worksheet the user is on, execute the
program which in this case is a webquery (which runs on a specific
worksheet), and return to the worksheet that the user was originally looking
at.

I'm thinking that the best way to do this is to first set a variable to the
name of the active worksheet, execute the program, and lastly to activate the
original worksheet by using the variable that was set in the first operation.

What do you guy think?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default worksheet name store in a variable

I'm sorry... I need the name of the active WORKSHEET to be stored in a
variable... not the name of the macro. Its late and I've been coding all
day...lol.

"Steve P" wrote:

Hi guys,
I'm finishing up a macro and need to store the name of the macro in a
variable.

I want the macro to find out what worksheet the user is on, execute the
program which in this case is a webquery (which runs on a specific
worksheet), and return to the worksheet that the user was originally looking
at.

I'm thinking that the best way to do this is to first set a variable to the
name of the active worksheet, execute the program, and lastly to activate the
original worksheet by using the variable that was set in the first operation.

What do you guy think?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default worksheet name store in a variable

Hi Steve,

Rather than getting the name of the worksheet you can store a reference to
the the sheet as in

Dim s As Object

Set s = ActiveSheet
MsgBox "do other stuff", vbOKOnly
s.Activate

Thats it done.

Notice I used an object because you are not sure if it is a worksheet or a
chart that will be active when the macro is run if you are sure that it will
only be a worksheet then:

Dim s As worksheet

Set s = ActiveSheet
MsgBox "do other stuff", vbOKOnly
s.Activate

is prefered.
--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Steve P" wrote:

I'm sorry... I need the name of the active WORKSHEET to be stored in a
variable... not the name of the macro. Its late and I've been coding all
day...lol.

"Steve P" wrote:

Hi guys,
I'm finishing up a macro and need to store the name of the macro in a
variable.

I want the macro to find out what worksheet the user is on, execute the
program which in this case is a webquery (which runs on a specific
worksheet), and return to the worksheet that the user was originally looking
at.

I'm thinking that the best way to do this is to first set a variable to the
name of the active worksheet, execute the program, and lastly to activate the
original worksheet by using the variable that was set in the first operation.

What do you guy think?

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
store variable keen learner Excel Programming 9 March 8th 06 02:26 PM
How to store current row into variable ilyaskazi[_81_] Excel Programming 1 October 12th 05 05:03 AM
How to store text to variable jafery Excel Programming 0 September 29th 05 10:18 AM
Store Variable with Exported Worksheet Stratuser Excel Programming 2 June 10th 05 09:31 PM
Store variable value for Chart Al Jager Excel Programming 1 February 19th 04 10:58 AM


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