Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to look for worksheet

I would greatly appreciate any assistance with this...
I'm new at working with macros and I am trying to record a
macro with which I am having no luck. I'm starting to
wonder if it can be done.
I have, in one workbook, a sheet where a user will type
the first 3 letters of any month of the year into cell A1.
Ideally I would like to record a macro which will then
basically 'look at' which 3 letters have been typed into
A1 and will go and find the Worksheet (in the same
Workbook) whose name matches.
So you type "Jan" into A1 of Sheet1
You then run the macro and it looks at the names (on the
tabs) of the other sheets in the workbook until it finds
the Worksheet with "Jan" on the tab.
Then I want to copy the contents of that sheet and paste
it elsewhere but I'm okay with that bit. I just need to
know how - if it's possible - to have a macro look at the
value of a particular cell then look for the sheet whose
name is equal to that value.
MANY MANY thanks
mercedes
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Macro to look for worksheet

Hi
try something like the following:
sub foo()
dim source_wks as worksheet
dim get_wks as worksheet
Dik wks_name
set get_wks = activesheet
wks_name=get_wks.range("A1").value
if wks_name="" then exit sub

on error resume next
set source_wks=worksheets(wks_name)
on error goto 0
if source_wks is nothing then
msgbox "Sheet does not exist"
exit sub
'your other code
end sub


-----Original Message-----
I would greatly appreciate any assistance with this...
I'm new at working with macros and I am trying to record

a
macro with which I am having no luck. I'm starting to
wonder if it can be done.
I have, in one workbook, a sheet where a user will type
the first 3 letters of any month of the year into cell A1.
Ideally I would like to record a macro which will then
basically 'look at' which 3 letters have been typed into
A1 and will go and find the Worksheet (in the same
Workbook) whose name matches.
So you type "Jan" into A1 of Sheet1
You then run the macro and it looks at the names (on the
tabs) of the other sheets in the workbook until it finds
the Worksheet with "Jan" on the tab.
Then I want to copy the contents of that sheet and paste
it elsewhere but I'm okay with that bit. I just need to
know how - if it's possible - to have a macro look at the
value of a particular cell then look for the sheet whose
name is equal to that value.
MANY MANY thanks
mercedes
.

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
Macro to name worksheet tabs using a cell within the worksheet? Jennifer Excel Discussion (Misc queries) 4 November 6th 12 05:03 PM
Macro to Create New Worksheet and Reference Cell in Old Worksheet As Tab Name - "Object Required" Error [email protected] Excel Discussion (Misc queries) 4 September 25th 06 01:35 PM
How? Macro to copy range to new worksheet, name new worksheet, loop Repoman Excel Programming 9 October 9th 03 01:45 PM
macro to apply worksheet event to active worksheet Paul Simon[_2_] Excel Programming 3 August 7th 03 02:50 AM
Record Worksheet Content as Macro and Execute from another Worksheet David McRitchie[_2_] Excel Programming 2 July 23rd 03 09:43 AM


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