Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Search and Replace

I'm wanting to search and replace a worksheet, but rather than replace with a
set bit of text, I want to replace it with something defined within my VBA
code:

Cells.Replace What:="Annuity L_All", Replacement:=file_noxls, LookAt _
:=xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

The "replace" text is definitely there, but when I run the code, it doesn't
repalce anything... can anyone help / spot the obvious error?

Thanks! :)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Search and Replace

Your code snippet works for me. Just out of curiosity, is the worksheet that
contains your "Annuity L_All" text the ActiveWorksheet (the Cells property
is not referencing any particular worksheet, so it will refer to the
ActiveSheet by default)?

--
Rick (MVP - Excel)


"Muttley" wrote in message
...
I'm wanting to search and replace a worksheet, but rather than replace
with a
set bit of text, I want to replace it with something defined within my VBA
code:

Cells.Replace What:="Annuity L_All", Replacement:=file_noxls, LookAt _
:=xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

The "replace" text is definitely there, but when I run the code, it
doesn't
repalce anything... can anyone help / spot the obvious error?

Thanks! :)


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Search and Replace

Refers ActiveSheet..

Dim file_noxls As String
file_noxls = "replaced"
Cells.Replace What:="Annuity L_All", _
Replacement:=file_noxls, SearchOrder:=xlByRows

If this post helps click Yes
---------------
Jacob Skaria


"Muttley" wrote:

I'm wanting to search and replace a worksheet, but rather than replace with a
set bit of text, I want to replace it with something defined within my VBA
code:

Cells.Replace What:="Annuity L_All", Replacement:=file_noxls, LookAt _
:=xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

The "replace" text is definitely there, but when I run the code, it doesn't
repalce anything... can anyone help / spot the obvious error?

Thanks! :)

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
search and replace Kiba Excel Programming 0 February 9th 09 02:20 PM
search and replace Kiba Excel Programming 0 February 9th 09 02:19 PM
Search and replace Subu Excel Worksheet Functions 4 June 9th 05 07:01 PM
Search and Replace help hodeware Excel Programming 1 April 1st 05 01:45 AM
Help with Search and Replace mak Excel Programming 3 November 29th 04 11:09 PM


All times are GMT +1. The time now is 03:55 PM.

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"