Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
psp psp is offline
external usenet poster
 
Posts: 3
Default How to get sheet name in formula or macro

Hi!

I need to write a macro/formula that uses the sheet name. I do not want to
type it in but want it as some type of function like sheetname(). Then using
that I like to manipulate the output of sheetname(). Can I do this? E.g., I
have name each of my sheet as date of the month (like"1", "2", etc.). I like
to get data from the previous day (worksheet). How can I do this without
manually typing it each time?

thank you,

prashant
--
Excel is excellent
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to get sheet name in formula or macro

set sh = ActiveSheet
sName = sh.Name
sName = cStr(clng(sName)-1)
if sName = "0" then
msgbox "No previous sheet"
exit sub
end if
set sh1 = sheets(sName)
msgbox sh1.Name


another is

set sh1 = activesheet.previous
msgbox sh1.Name

this assume the sheets are sequential in the tab order.



--
Regards,
Tom Ogilvy

"psp" wrote in message
...
Hi!

I need to write a macro/formula that uses the sheet name. I do not want to
type it in but want it as some type of function like sheetname(). Then

using
that I like to manipulate the output of sheetname(). Can I do this? E.g.,

I
have name each of my sheet as date of the month (like"1", "2", etc.). I

like
to get data from the previous day (worksheet). How can I do this without
manually typing it each time?

thank you,

prashant
--
Excel is excellent



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default How to get sheet name in formula or macro

hi,
you didn't say what ranges on the previous sheet you need
to copy so....
sniplet
activesheet.previous.select
'your copy code here
seletion.copy
activesheet.next.select
'paste it somewhere.
this code sniplet will go to the previous sheet from
active sheet, copy some data, return to the the first
sheet you were on and paste the data somewhere.
good luck

-----Original Message-----
Hi!

I need to write a macro/formula that uses the sheet name.

I do not want to
type it in but want it as some type of function like

sheetname(). Then using
that I like to manipulate the output of sheetname(). Can

I do this? E.g., I
have name each of my sheet as date of the month

(like"1", "2", etc.). I like
to get data from the previous day (worksheet). How can I

do this without
manually typing it each time?

thank you,

prashant
--
Excel is excellent
.

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 lookup a sheet, number, then display in origonal sheet abbsy3 New Users to Excel 3 November 9th 10 12:19 PM
Formula in macro or in sheet/cells? Heine Excel Worksheet Functions 10 November 3rd 06 11:02 PM
macro adding formula to new sheet toddsavage100 Excel Discussion (Misc queries) 2 March 14th 06 03:03 AM
2 questions, copying data from sheet to sheet and assigning macro Boris Excel Worksheet Functions 0 December 16th 04 06:11 PM
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet arunjoshi[_5_] Excel Programming 1 May 2nd 04 03:50 PM


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