Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Default Macro to add new sheet and then fill formula in a totals sheet to refernce this sheet

Hi all,

I have created a macro to copy the template sheet and name the sheet based on the last sheet, so sheet names are 1,2,3 etc

Sheets("TemplateSheet").Copy After:=Sheets(ActiveWorkbook.Sheets.Count)
ActiveSheet.Previous.Select
Range("C6").Copy
ActiveSheet.Next.Select
Range("c6").PasteSpecial xlPasteValues
Range("c6").Value = Range("c6").Value + 1
ActiveSheet.Name = Format(Range("c6").Value, "#")

This works fine but i also want to add to the macro to copy this formula =IF('1'!A$3="","",'1'!A$3) to the next row but to reference the new worksheet so it would be =IF('2'!A$3="","",'2'!A$3). Does anyone know how I can do this?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,872
Default Macro to add new sheet and then fill formula in a totals sheet to refernce this sheet

Hi Sophs,

Am Thu, 12 Jul 2012 15:17:38 +0000 schrieb Sophs:

Sheets("TemplateSheet").Copy After:=Sheets(ActiveWorkbook.Sheets.Count)
ActiveSheet.Previous.Select
Range("C6").Copy
ActiveSheet.Next.Select
Range("c6").PasteSpecial xlPasteValues
Range("c6").Value = Range("c6").Value + 1
ActiveSheet.Name = Format(Range("c6").Value, "#")


try instead:
Sheets("Template Sheet").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = _
Sheets(Sheets.Count - 1).Range("C6") + 1

This works fine but i also want to add to the macro to copy this formula
=IF('1'!A$3="","",'1'!A$3) to the next row but to reference the new
worksheet so it would be =IF('2'!A$3="","",'2'!A$3). Does anyone know
how I can do this?


Which cell contains this formula?


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
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
formula for totals throughout sheet Dottled Excel Discussion (Misc queries) 3 January 26th 09 03:53 PM
Refernce sheet names in if statement Sabosis Excel Programming 4 October 31st 08 06:59 PM
"='sheet 1'!D4" auto fill sheet to sheet ='sheet 2'!D4 mistewalker Excel Worksheet Functions 5 January 6th 08 11:36 PM
counting like items on one sheet, showing totals on another sheet RPW Excel Programming 3 October 6th 06 08:36 PM
Conditionally Fill a sheet row if cell value in another sheet 0 nstx Excel Worksheet Functions 2 November 6th 05 03:04 PM


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