![]() |
Error for a replace. It replace ALL instead of selected column
Hi, I need to find a column and make a copy of it somewhere (for backup
reference). Then, for the first column (the one I copied) I need to replace a number by a city name. The problem is that ALL of the said number in the sheet ias replace by the city name. I thought by selecting and activate the column it would prevent to do this, but it's not working properly. Below is the code I use. Thank you! Range("A1").Select Cells.Find(What:="Plnt", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ , SearchFormat:=False).Activate Selection.Resize(numRows + 30000, numColumns + 1).Select Selection.Copy Range("A1").End(xlToRight).Select ActiveCell.Offset(0, 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Cells.Find(What:="Plnt", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ , SearchFormat:=False).Activate Selection.Resize(numRows + 30000, numColumns + 1).Select Cells.Replace What:="2110", Replacement:="Joliette", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False -- Mathieu |
Error for a replace. It replace ALL instead of selected column
HI,
Use : Selection.Replace instead of Cells.Replace Regards. Daniel Hi, I need to find a column and make a copy of it somewhere (for backup reference). Then, for the first column (the one I copied) I need to replace a number by a city name. The problem is that ALL of the said number in the sheet ias replace by the city name. I thought by selecting and activate the column it would prevent to do this, but it's not working properly. Below is the code I use. Thank you! Range("A1").Select Cells.Find(What:="Plnt", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ , SearchFormat:=False).Activate Selection.Resize(numRows + 30000, numColumns + 1).Select Selection.Copy Range("A1").End(xlToRight).Select ActiveCell.Offset(0, 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Cells.Find(What:="Plnt", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ , SearchFormat:=False).Activate Selection.Resize(numRows + 30000, numColumns + 1).Select Cells.Replace What:="2110", Replacement:="Joliette", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False |
Error for a replace. It replace ALL instead of selected column
Thank you!
-- Mathieu "Daniel.C" wrote: HI, Use : Selection.Replace instead of Cells.Replace Regards. Daniel Hi, I need to find a column and make a copy of it somewhere (for backup reference). Then, for the first column (the one I copied) I need to replace a number by a city name. The problem is that ALL of the said number in the sheet ias replace by the city name. I thought by selecting and activate the column it would prevent to do this, but it's not working properly. Below is the code I use. Thank you! Range("A1").Select Cells.Find(What:="Plnt", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ , SearchFormat:=False).Activate Selection.Resize(numRows + 30000, numColumns + 1).Select Selection.Copy Range("A1").End(xlToRight).Select ActiveCell.Offset(0, 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Cells.Find(What:="Plnt", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ , SearchFormat:=False).Activate Selection.Resize(numRows + 30000, numColumns + 1).Select Cells.Replace What:="2110", Replacement:="Joliette", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False |
All times are GMT +1. The time now is 09:44 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com