Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Replacing Sheet name in formula

I have a sheet with formulae in the format:

=SUM(OFFSET('Centre 1'!$F17,,('Centre 1'!F$8-1)*12):OFFSET('Centre
1'!$F17,,F$8*12-1)),

the purpose of which is to sum monthly figures into annual ones. I want to
replace 'Centre 1' with another centre anything from 1 - 10. I have a drop
down box in a cell named CentreNameChoice.

I was trying to do it via VBA using something like:

Sub CentreSummaryChoice()
'
' CentreSummaryChoice Macro
' Macro recorded 21/07/2006 by Ron McCormick
'

'
Range("CentreNameInput").Select
ActiveCell.FormulaR1C1 = "=""'""&CentreNameChoice&""'"""
Range("CentreNameInput").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("TenYearSummary").Select
Cells.Replace What:="'Centre??'", Replacement:=CentreNameInput, LookAt:= _
xlPart, SearchOrder:=xlByColumns, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False
End Sub

but it does not seem to work.

Is there and Excel function that I can use directly in my Excel formula,
that will remove the need for the macro or can someone advise how I need to
amend my code.

Thanks

Ron


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Replacing Sheet name in formula

You can use the indirect function directly in your Excel Formula something
like this...

=SUM(OFFSET(Indirect("'Centre " & CentreNameInput &
"'!$F17"),,(Indirect("'Centre " & CentreNameInput & "'!$F8")
-1)*12):OFFSET(Indirect("'Centre " & CentreNameInput & "'!$F17"),,F$8*12-1)),

I think the formula you posted is a little off in it's commas???
--
HTH...

Jim Thomlinson


"Ron McCormick" wrote:

I have a sheet with formulae in the format:

=SUM(OFFSET('Centre 1'!$F17,,('Centre 1'!F$8-1)*12):OFFSET('Centre
1'!$F17,,F$8*12-1)),

the purpose of which is to sum monthly figures into annual ones. I want to
replace 'Centre 1' with another centre anything from 1 - 10. I have a drop
down box in a cell named CentreNameChoice.

I was trying to do it via VBA using something like:

Sub CentreSummaryChoice()
'
' CentreSummaryChoice Macro
' Macro recorded 21/07/2006 by Ron McCormick
'

'
Range("CentreNameInput").Select
ActiveCell.FormulaR1C1 = "=""'""&CentreNameChoice&""'"""
Range("CentreNameInput").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("TenYearSummary").Select
Cells.Replace What:="'Centre??'", Replacement:=CentreNameInput, LookAt:= _
xlPart, SearchOrder:=xlByColumns, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False
End Sub

but it does not seem to work.

Is there and Excel function that I can use directly in my Excel formula,
that will remove the need for the macro or can someone advise how I need to
amend my code.

Thanks

Ron


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Replacing Sheet name in formula

Jim,

Thanks for your help. I thougt the INDIRECT function might help, though
it's one I'm not very familiar with, but how do I get absolute and relative
cell references to work within the formula when I copy it across rows and
down columns?

TIA
Ron

"Jim Thomlinson" wrote:

You can use the indirect function directly in your Excel Formula something
like this...

=SUM(OFFSET(Indirect("'Centre " & CentreNameInput &
"'!$F17"),,(Indirect("'Centre " & CentreNameInput & "'!$F8")
-1)*12):OFFSET(Indirect("'Centre " & CentreNameInput & "'!$F17"),,F$8*12-1)),

I think the formula you posted is a little off in it's commas???
--
HTH...

Jim Thomlinson


"Ron McCormick" wrote:

I have a sheet with formulae in the format:

=SUM(OFFSET('Centre 1'!$F17,,('Centre 1'!F$8-1)*12):OFFSET('Centre
1'!$F17,,F$8*12-1)),

the purpose of which is to sum monthly figures into annual ones. I want to
replace 'Centre 1' with another centre anything from 1 - 10. I have a drop
down box in a cell named CentreNameChoice.

I was trying to do it via VBA using something like:

Sub CentreSummaryChoice()
'
' CentreSummaryChoice Macro
' Macro recorded 21/07/2006 by Ron McCormick
'

'
Range("CentreNameInput").Select
ActiveCell.FormulaR1C1 = "=""'""&CentreNameChoice&""'"""
Range("CentreNameInput").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("TenYearSummary").Select
Cells.Replace What:="'Centre??'", Replacement:=CentreNameInput, LookAt:= _
xlPart, SearchOrder:=xlByColumns, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False
End Sub

but it does not seem to work.

Is there and Excel function that I can use directly in my Excel formula,
that will remove the need for the macro or can someone advise how I need to
amend my code.

Thanks

Ron


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
Replacing sheet causes #REF Homer Excel Discussion (Misc queries) 4 July 31st 09 07:59 PM
replacing Sheet create_share Excel Discussion (Misc queries) 1 August 1st 06 12:49 PM
Replacing sheet reference in multiple cells... neilcarden Excel Worksheet Functions 3 June 23rd 06 05:00 PM
replacing just the sheet names within formulas Jeanne Criez Excel Worksheet Functions 1 January 4th 05 06:27 PM
Replacing One Sheet in Several Files Mark[_22_] Excel Programming 5 January 17th 04 10:11 AM


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