Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default copying a template sheet and inputting a formula into another sheetthat references the new sheet

Hi here is the section of code that I am having problems with, I have
it commented to help anyone understand what I am doing. Everything
works except for the last line of code. The big picture of what I am
trying to do is to make a copy of an existing template worksheet that
I have setup, then I want the macro to input a formula into the my
Main worksheet that references cells in the newly created worksheet.


'This variable store the name of the new sheet that it gets from an
existing cell
newSht = ActiveCell.FormulaR1C1

‘Creating a copy of the template worksheet and renaming it to the
value stored in variable newSht
Sheets("Worksheet Template").Select
Sheets("Worksheet Template").Copy Befo=Sheets(3)
ActiveSheet.Name = newSht

‘Inputting a formula to the main worksheet that references the newly
created template copy
Sheets("Main Worksheet").Select
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=('newsht'!R30C7*'newsht'!R51C7)"



Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default copying a template sheet and inputting a formula into anothersheet that references the new sheet

Change the last line as follows:
ActiveCell.FormulaR1C1 = "=('" & newsht & "'!R30C7*'" & newsht & "'!
R51C7)"
The variable needs to be referenced outside of the quotation marks.
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
help with copying of excel spread sheet from template trought VB Mike[_129_] Excel Programming 2 July 25th 09 05:30 PM
Copying a formatted "template" sheet and naming new sheet via user form Neale[_2_] Excel Programming 1 May 31st 07 04:02 PM
Copying sheet containing GetPivotData, new sheet references old workbook! rivkarak Excel Programming 0 January 18th 07 11:31 AM
copying sheet references that refer to a cell in the preceding she GBT Excel Worksheet Functions 1 March 24th 06 07:51 PM
relative sheet references ala sheet(-1)!B11 so I can copy a sheet. RonMc5 Excel Discussion (Misc queries) 9 February 3rd 05 12:51 AM


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