MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

how do I get the current worksheet name into a variabl

  Asked By: Rani    Date: Nov 28    Category: MS Office    Views: 2111

I'm trying to modify a macro so it will run in each worksheet, instead
of making one for each sheet.

The macro copies some data from the previous sheet (each month of the
year has it's own sheet but the order may get changed). So I want to
program the macro to read the current active worksheet name and based
on that go to the previous month.

I've found you can get the name by entering worksheet(number).name,
but then the problem just shifts to getting the current worksheet number.

Which command can I used to solve my problem?



2 Answers Found

Answer #1    Answered By: Sean Grant     Answered On: Nov 28

I think you are looking for the ActiveSheet Property. If you
search on "ActiveSheet" in VBA Help, and choose "ActiveSheet
Property", you will find what you need including this Example:

This example displays the name  of the active  sheet.

MsgBox "The name of the active sheet  is " & ActiveSheet.Name

So, for your application you want to find the Sheet.Name that
matches ActiveSheet.Name and then take the appropriate action.

Answer #2    Answered By: Huette Miller     Answered On: Nov 28

try activeworksheet.name......................

Didn't find what you were looking for? Find more on how do I get the current worksheet name into a variabl Or get search suggestion and latest updates.