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,560
Default Update Formulas on Consecutive Sheets in a Range

When I add sheets, I have copy a base sheet (P1) and paste it to a new sheet.
I have a macro that copies the row and column properties and then applies it
to the new sheets.
What I want to do now is run a macro to change the formulas. A simple
replace command works, but I need code that will advance by one for each new
sheet. I recorded the macro below to give you a feel of what I am trying to
do. I have sheets P1 to P30, but could have more P? sheets, up to 100. All
the sheets will have the same formulas, just 1 more than the previous sheet.
You can assume always running the macro from the P1 sheet. The initial
formula always starts with column 17 and each each thereafter must be +1,
then +2, etc.
Thanks in advance!

Sub UpdateFormulas()
Sheets("P3").Select
Range("C15:I15").Select
Selection.Replace What:="17", Replacement:="19", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("C24:I24").Select
Selection.Replace What:="17", Replacement:="19", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Sheets("P4").Select
Range("C15:I15").Select
Selection.Replace What:="17", Replacement:="20", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("C24:I24").Select
Selection.Replace What:="17", Replacement:="20", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Sheets("P5").Select
End Sub
 
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
Consecutive date range on consecutive worksheets john3478 Excel Worksheet Functions 3 January 14th 09 10:54 PM
generating consecutive sheets with macros des-sa[_2_] Excel Discussion (Misc queries) 2 July 2nd 08 10:23 PM
using weekday formulas to automatically update a date range ascott Excel Discussion (Misc queries) 1 March 5th 08 09:23 PM
Auto update the chart range for new sheets Access Joe Charts and Charting in Excel 2 December 13th 07 06:42 PM
Consecutive Date Formulas Codye Excel Discussion (Misc queries) 1 April 14th 05 04:50 PM


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