LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default replace formula references with previous sheet names

Hi,

I have a workbook with a macro that copies my template sheet, inserts
it as a new sheet at the end of all the sheets, and renames the new
sheet to Week x+1, one higher than the sheet before.

I have several cells that refer to the previous sheet, using INDIRECT
and PrevSheet:
Function PrevSheet()
'=INDIRECT("'"&PrevSheet()&"'!D48")
On Error GoTo EndFunction
Application.Volatile True
PrevSheet = Application.Caller.Worksheet.Previous.Name
Exit Function
EndFunction:
With Application.Caller.Parent.Parent.Worksheets
PrevSheet = .Item(.Count).Name
End With
End Function

The problem with this is that I add rows to my sheets, which means that
the information I'm targeting is no longer in D48, and the INDIRECT
reference doesn't change.

I was wondering if, on my template sheet, I can replace
=INDIRECT("'"&PrevSheet()&"'!D48") with =?D48 and then have a macro
search out the name of the previous sheet, and replace all the ? on my
new sheet with that name. So after the macro has run, the cell in
question will now read ='Week 24 2006'!D54 (or equivalent). Hopefully,
that reference will then change as I add rows to the sheet called Week
24 2006.

Any suggestions?

Thanks for any help you can give,
Helen

 
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
Replace cell references with names hmm Excel Discussion (Misc queries) 3 November 17th 08 03:09 PM
How to replace single cell references with row names? Dima Excel Discussion (Misc queries) 2 August 11th 08 11:43 AM
How to replace single cell references with row names? Dima Excel Worksheet Functions 2 August 11th 08 11:43 AM
Replace range names with cell references? KH Excel Worksheet Functions 2 August 2nd 05 01:09 AM
Sheet Names and Cell References Reed Excel Worksheet Functions 1 January 19th 05 10:17 PM


All times are GMT +1. The time now is 02:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"