Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 287
Default VBA, find and replace

I am having a hard time trying to write a macro that does a find and replace
function on the workbook and then does another one on just a spreadsheet.
I've been googling vba code and haven't found a result. When I record the
macro myself, the code continues to return the same despite the function
running on a within a workbook and then just within a spreadsheet...

On the workbook...
Cells.Replace What:="Projections!n3", Replacement:="Projections!$n$3", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:= _
False, ReplaceFormat:=False

On the worksheet...
Sheets("Projections").Select
Cells.Replace What:="n2=", Replacement:="$n$2=", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default VBA, find and replace

You could loop through the worksheets:

dim wks as worksheet
for each wks in activeworkbook.worksheets
wks.Cells.Replace What:="n2=", Replacement:="$n$2=", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
next wks




Aaron wrote:

I am having a hard time trying to write a macro that does a find and replace
function on the workbook and then does another one on just a spreadsheet.
I've been googling vba code and haven't found a result. When I record the
macro myself, the code continues to return the same despite the function
running on a within a workbook and then just within a spreadsheet...

On the workbook...
Cells.Replace What:="Projections!n3", Replacement:="Projections!$n$3", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:= _
False, ReplaceFormat:=False

On the worksheet...
Sheets("Projections").Select
Cells.Replace What:="n2=", Replacement:="$n$2=", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Any ideas?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,311
Default VBA, find and replace

If you want a great tool for finding and replacing in an entire workbook or
workbooks and not just a single worksheet at a time, check out "flexfind".
This is an add-in. It really works wonders.

http://www.jkp-ads.com/FlexfindScreenshot.htm



--

"Aaron" wrote in message
...
I am having a hard time trying to write a macro that does a find and
replace
function on the workbook and then does another one on just a spreadsheet.
I've been googling vba code and haven't found a result. When I record the
macro myself, the code continues to return the same despite the function
running on a within a workbook and then just within a spreadsheet...

On the workbook...
Cells.Replace What:="Projections!n3", Replacement:="Projections!$n$3",
_
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:= _
False, ReplaceFormat:=False

On the worksheet...
Sheets("Projections").Select
Cells.Replace What:="n2=", Replacement:="$n$2=", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Any ideas?



Reply
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
Find and Replace - Replace with Blank Space Studebaker Excel Discussion (Misc queries) 4 April 3rd 23 10:55 AM
where to put results of find operation in find and replace functio DEP Excel Worksheet Functions 5 November 15th 06 07:52 PM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
Using Find and Replace All HandsOnManager Excel Worksheet Functions 0 February 15th 05 07:43 PM
find replace cursor default to find box luffa Excel Discussion (Misc queries) 0 February 3rd 05 12:11 AM


All times are GMT +1. The time now is 05:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"