Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
replace doesn't
In XL2000, I use the following sub to update some stuff each month, but the
Replace portion doesn't replace anything :( Cells B42 and G42 contain formulas that link to cells in 'Foodcost.xls' No errors occur, but it's probably some simple syntax problem I can't solve. Any help? Sub Renew() Dim OldMonth As String Dim NewMonth As String Dim wkbk As Workbook Set wkbk = ActiveWorkbook Application.ScreenUpdating = False Workbooks.Open "Foodcost.xls" wkbk.Activate Range("Initial_Qty").Value = Range("On_Hand").Value Range("Added_Used").ClearContents OldMonth = Workbooks("Foodcost.xls").Sheets(5).Name 'i.e. Dec NewMonth = Workbooks("Foodcost.xls").Sheets(6).Name 'i.e. Jan Range("B42,G42").Cells.Replace What:=OldMonth, Replacement:=NewMonth, LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False Workbooks("Foodcost.xls").Close Application.ScreenUpdating = True End Sub -- David |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
replace doesn't
David,
Did you mean for this to be all of the columns from B to G in Row 42? Try "B42:G42" rather than "B42,G42" -Donna -----Original Message----- In XL2000, I use the following sub to update some stuff each month, but the Replace portion doesn't replace anything :( Cells B42 and G42 contain formulas that link to cells in 'Foodcost.xls' No errors occur, but it's probably some simple syntax problem I can't solve. Any help? Sub Renew() Dim OldMonth As String Dim NewMonth As String Dim wkbk As Workbook Set wkbk = ActiveWorkbook Application.ScreenUpdating = False Workbooks.Open "Foodcost.xls" wkbk.Activate Range("Initial_Qty").Value = Range("On_Hand").Value Range("Added_Used").ClearContents OldMonth = Workbooks("Foodcost.xls").Sheets (5).Name 'i.e. Dec NewMonth = Workbooks("Foodcost.xls").Sheets (6).Name 'i.e. Jan Range("B42,G42").Cells.Replace What:=OldMonth, Replacement:=NewMonth, LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False Workbooks("Foodcost.xls").Close Application.ScreenUpdating = True End Sub -- David . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
replace doesn't
Sharqua wrote
Did you mean for this to be all of the columns from B to G in Row 42? No. I only wanted to look at two cells (B42 and G42)... however: Range("B42,G42").Cells.Replace What:=OldMonth, Replacement:=NewMonth, Doh! Discovered I was referencing the wrong row! Changed to 41 and all is well :) Forgot I had recently deleted a row after macro was written. Thanks for jumping in, though. -- David |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
replace doesn't
Name the cells and refer to the name and that won't happen again
-- Don Guillett SalesAid Software "David" wrote in message ... Sharqua wrote Did you mean for this to be all of the columns from B to G in Row 42? No. I only wanted to look at two cells (B42 and G42)... however: Range("B42,G42").Cells.Replace What:=OldMonth, Replacement:=NewMonth, Doh! Discovered I was referencing the wrong row! Changed to 41 and all is well :) Forgot I had recently deleted a row after macro was written. Thanks for jumping in, though. -- David |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
replace doesn't
Don Guillett wrote
Name the cells and refer to the name and that won't happen again Done. Thanks. -- David |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find and Replace - Replace with Blank Space | Excel Discussion (Misc queries) | |||
Can I replace a ' at the beginning of a text cell using Replace | Excel Discussion (Misc queries) | |||
Replace dialog should put focus on "Find What" not "Replace With" | Excel Discussion (Misc queries) | |||
find and replace - replace data in rows to separated by commas | Excel Worksheet Functions | |||
How can I use replace(alt+H) for mutiple items needing replace | Excel Worksheet Functions |