LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 846
Default Macro that isn't working

Thought that might be the case and I was sooo close to the right answer - was
missing the leading "." in front of the cell.replace

As always - Jim - thanks for the help....

"Jim Thomlinson" wrote:

The code you have only works onthe active sheet. This line
Cells.Replace ...
is executed as
Activesheet.Cells.Replace

You need to create worksheet object and travers through all of the sheets

Sub MakeTheChange()
Dim inpStr1 As String
Dim inpStr2 As String
Dim inpStr3 As String
Dim inpStr4 As String
Dim inpStr5 As String
Dim inpStr6 As String
dim wks as worsheet

inpStr1 = "Intranet12|01|09"
inpStr2 = "Intranet11|10|09"
inpStr3 = "Intranet09|01|09"
inpStr4 = "Rates12|01|09"
inpStr5 = "Rates11|10|09"
inpStr6 = "Rates09|01|09"

for each wks in worksheets
with wks
.Cells.Replace What:=inpStr2, Replacement:=inpStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:= _
False, ReplaceFormat:=False
.Cells.Replace What:=inpStr3, Replacement:=inpStr2, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:= _
False, ReplaceFormat:=False
end with
next wks
Sheets(inpStr5).Name = inpStr4
Sheets(inpStr6).Name = inpStr5

End Sub
--
HTH...

Jim Thomlinson


"Brad" wrote:

Should be really simple, but I'm missing something basic.
In the Cell.Replace (I want to replace the formula for the entire workbook)
&
If this can be simplified - I would appreciate it...


Sub MakeTheChange()
Dim inpStr1 As String
Dim inpStr2 As String
Dim inpStr3 As String
Dim inpStr4 As String
Dim inpStr5 As String
Dim inpStr6 As String

inpStr1 = "Intranet12|01|09"
inpStr2 = "Intranet11|10|09"
inpStr3 = "Intranet09|01|09"
inpStr4 = "Rates12|01|09"
inpStr5 = "Rates11|10|09"
inpStr6 = "Rates09|01|09"

Cells.Replace What:=inpStr2, Replacement:=inpStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:= _
False, ReplaceFormat:=False
Cells.Replace What:=inpStr3, Replacement:=inpStr2, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:= _
False, ReplaceFormat:=False

Sheets(inpStr5).Name = inpStr4
Sheets(inpStr6).Name = inpStr5

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
Macro working bar Alberto Ast[_2_] Excel Discussion (Misc queries) 14 September 12th 09 03:12 PM
macro is not working? Derrick Excel Discussion (Misc queries) 5 June 23rd 09 01:51 PM
MACRO IS NOT WORKING AS IT SHOULD jeannie v Excel Worksheet Functions 3 June 21st 07 08:19 AM
macro not working dpolston Excel Discussion (Misc queries) 2 April 19th 07 09:16 PM
macro not working Jonathan Cooper Excel Discussion (Misc queries) 1 February 1st 06 10:06 PM


All times are GMT +1. The time now is 09:43 PM.

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"