Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default relative sheet referencing

I'm stumped!!

In Excel 2000:

One workbook, starting with 2 "master" sheets (used as templates for
additional sheets)


TEMPlocation
TEMPsummary (with formulas that reference TEMPlocation!)

These sheets are normally hidden.

Upon user opening for for the first time:

I have a macro that allows user to input 4 char "location" code, then the
macro copies and renames two NEW sheets (concatenating the code) as follows:

locCode = inputbox...
Sheets("TEMPlocation").Visible = True
Sheets("TEMPlocation").Copy After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = locCode & "location"

Sheets("TEMPsummary").Visible = True
Sheets("TEMPsummary").Copy After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = locCode & "summary"

Upon reviewing the new location sheets, I notice the formulas in LOC1summary
still reference the original "TEMPlocation" sheet instead of the
"LOC1location" sheet.

I understand if I RENAME the sheets, Excel will update the formulas, but
I'll lose my template files for future additions.

I've attepted many different scenarios of copying, then renaming but I can't
seem to save the original sheets, and make new sheets that Excel will update
references to each other.

My closest solution has been by "hardcoding a reference" by creating a named
range (cell) that stores the text location code, then reference that cell
using the INDIRECT function to create the formula sheet reference (as
follows):

Cell A1 (value): LOC1

Formula cell B2 on same sheet: =INDIRECT(TRIM($A$1) & "location!L73")

resulting in (formula): =LOC1location!L73

This works - sort of....

The concern here is that the cell reference on the target sheet is absolute,
and if rows/columns are added/deleted this will kill the formula.

Is there a way to make the target cell reference (which is on a different
sheet) relative?

I also attempted to create a function passing in target cell reference
(cleaner - but still gets processed as absolute by excel).

OR

Is there a better way to copy / rename the sheets originally so that Excel
simply updates the formula references?

Thanks in advance for you consideration!

Regards,
Glenn


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default relative sheet referencing

when you create the summary sheet, place the source sheet name
into Range("A1")
eg
Worksheets(locCode & "Summary").Range("A1")=locCode & "Location"
If you change the absolute references in the template to use the INDIRECT()
function, referenceing the cell A1, then your summary will work so long as A1
has the name of a worksheet.




"Glenn" wrote:

I'm stumped!!

In Excel 2000:

One workbook, starting with 2 "master" sheets (used as templates for
additional sheets)


TEMPlocation
TEMPsummary (with formulas that reference TEMPlocation!)

These sheets are normally hidden.

Upon user opening for for the first time:

I have a macro that allows user to input 4 char "location" code, then the
macro copies and renames two NEW sheets (concatenating the code) as follows:

locCode = inputbox...
Sheets("TEMPlocation").Visible = True
Sheets("TEMPlocation").Copy After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = locCode & "location"

Sheets("TEMPsummary").Visible = True
Sheets("TEMPsummary").Copy After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = locCode & "summary"

Upon reviewing the new location sheets, I notice the formulas in LOC1summary
still reference the original "TEMPlocation" sheet instead of the
"LOC1location" sheet.

I understand if I RENAME the sheets, Excel will update the formulas, but
I'll lose my template files for future additions.

I've attepted many different scenarios of copying, then renaming but I can't
seem to save the original sheets, and make new sheets that Excel will update
references to each other.

My closest solution has been by "hardcoding a reference" by creating a named
range (cell) that stores the text location code, then reference that cell
using the INDIRECT function to create the formula sheet reference (as
follows):

Cell A1 (value): LOC1

Formula cell B2 on same sheet: =INDIRECT(TRIM($A$1) & "location!L73")

resulting in (formula): =LOC1location!L73

This works - sort of....

The concern here is that the cell reference on the target sheet is absolute,
and if rows/columns are added/deleted this will kill the formula.

Is there a way to make the target cell reference (which is on a different
sheet) relative?

I also attempted to create a function passing in target cell reference
(cleaner - but still gets processed as absolute by excel).

OR

Is there a better way to copy / rename the sheets originally so that Excel
simply updates the formula references?

Thanks in advance for you consideration!

Regards,
Glenn



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
Referencing Relative Sheets jwatters Excel Worksheet Functions 4 January 4th 09 03:39 AM
Relative sheet referencing in excel formulas MichaelR Excel Worksheet Functions 1 June 3rd 08 11:19 PM
relative sheet referencing - what's the secret? Glennster Excel Programming 1 October 21st 05 01:21 PM
macro relative referencing harriet Excel Discussion (Misc queries) 5 February 15th 05 01:40 PM
Relative referencing Dave Peterson[_3_] Excel Programming 0 August 21st 04 12:37 AM


All times are GMT +1. The time now is 03:36 PM.

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"