![]() |
Find and replace within a column
Hello, I tried to use vba to perform find and replace for the first 2 columns of a few sheets say the column F1 Sheets(2).Range("F1").Select Selection.Replace what:=" ", Replacement:="_", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False But in the end, all of the cells are processed. I'd like to know how should I limit the find and replace range properly? -- level3 ------------------------------------------------------------------------ level3's Profile: http://www.excelforum.com/member.php...o&userid=34541 View this thread: http://www.excelforum.com/showthread...hreadid=543036 |
Find and replace within a column
Range("F:G").Select
THEN do the find "level3" wrote: Hello, I tried to use vba to perform find and replace for the first 2 columns of a few sheets say the column F1 Sheets(2).Range("F1").Select Selection.Replace what:=" ", Replacement:="_", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False But in the end, all of the cells are processed. I'd like to know how should I limit the find and replace range properly? -- level3 ------------------------------------------------------------------------ level3's Profile: http://www.excelforum.com/member.php...o&userid=34541 View this thread: http://www.excelforum.com/showthread...hreadid=543036 |
Find and replace within a column
That is...
Range("F:G").Replace what:=" ", Replacement:="_", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False (No need to select first) "level3" wrote: Hello, I tried to use vba to perform find and replace for the first 2 columns of a few sheets say the column F1 Sheets(2).Range("F1").Select Selection.Replace what:=" ", Replacement:="_", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False But in the end, all of the cells are processed. I'd like to know how should I limit the find and replace range properly? -- level3 ------------------------------------------------------------------------ level3's Profile: http://www.excelforum.com/member.php...o&userid=34541 View this thread: http://www.excelforum.com/showthread...hreadid=543036 |
Find and replace within a column
Hi Bob, Thanks for the reply I tried many ways including your suggestion and something like this Sheets(2).Activate Range("A:B").Select Selection.Replace what:="_", Replacement:=" ", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("F:G").Select Selection.Replace what:=" ", Replacement:="_", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False But still, every cells' spaces are converted to underscore. even though I turned on the screen update and saw the selections were made correctly -- level3 ------------------------------------------------------------------------ level3's Profile: http://www.excelforum.com/member.php...o&userid=34541 View this thread: http://www.excelforum.com/showthread...hreadid=543036 |
All times are GMT +1. The time now is 10:24 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com