View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_2_] Patrick Molloy[_2_] is offline
external usenet poster
 
Posts: 1,298
Default How to do this in VBA?

why don't you simply use the Find/Replace method straight from the Edit menu
item?
Use a macro recorder to view the code thus generated. It'll give you pretty
all you need.

Here is the macro I just recorded, called macro1 and below my edited and
renamed procedure

Sub macro1()
'
' RepaceWith Macro
' Macro recorded 04/05/2005 by pmolloy
'

'
Columns("H:I").Select
Selection.Replace What:="what", Replacement:="with this", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
Sub RepaceWith()
Columns("H:I").Replace What:="what", Replacement:="with this"
End Sub


"Paul" wrote:

I have an Excel workbook with multiple columns and thousand and thousand
rows of data. I want to create a function to loop throught two of the
columns to find a pre-defined search word and replace it with something. I
want to create this in a function on a button. I am new to Excel coding, the
part That I am not sure is how to loop throught a select range (column) to
the end of the row on that column to find the serach word and then it moves
to the next column and finish it to the end of the row of the second column.
Thanks.