LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default How to create a massive find & replace macro

Here is another, more useful, routine for large quantities of data. The idea
is that you would have a separate workbook or, at least, a separate sheet for
the routine.

Column "A" would hold your names, "B" would hold the respective account
numbers. The report would be pasted on Columns "C" through howver many a are
in the report with the account numbers in column "D". The procedure will
replace the account numbers in "D" with their proper names from "B" as the
routine matches numbers.


Sub Replacethem()
Dim sAddr As String
Dim rngA As Range, rngB As Range
Dim rng As Range, cell As Range
Dim res As Variant

With Worksheets("Sheet1")

Set rngB = .Range(.Cells(2, 2), .Cells(2, 2).End(xlDown))
Set rngC = .Range(.Cells(2, 3), .Cells(2, 3).End(xlDown))

For Each cell In rngB
Set rng = rngC.Find(cell.Value, _
After:=rngC(rngC.Count), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If Not rng Is Nothing Then
sAddr = rng.Address

Do

rng.Offset(0, 1) = cell.Offset(0, -1).Value
Set rng = rngC.FindNext(rng)
Loop While rng.Address < sAddr

End If
Next
End Sub

--
Best wishes,

Jim


"JWCrosby" wrote:

I may be in the wrong newsgroup and if so, please direct me to the right one.

Our main database program (non-Excel) creates a file that can be opened in
Excel. The file I'm working with has code numbers in it, similar to account
numbers. I want to "convert" the account numbers to their actual name. So
far, I've accomplished that by doing a manual "find & replace" for each
account number (e.g., "find all the occurrances of '12345' and replace it
with "General Income"")

How could I write a macro to accomplish this for me? I'd like one where I
could easily add a new number and description.

Any ideas?

Thanks in advance.

Jerry

 
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
Massive Find and Replace Brian D Excel Discussion (Misc queries) 3 December 10th 08 02:58 PM
find a specific or several values in a massive datasheet walli Excel Worksheet Functions 2 November 19th 07 06:51 AM
create a form and find a value in one cell and replace a value in JCM Excel Worksheet Functions 1 October 1st 07 10:59 AM
Using Find and Replace to replace " in a macro snail30152 Excel Programming 1 April 13th 06 11:58 PM
A Macro to Do Find and Replace Eric Excel Programming 2 February 27th 04 12:22 AM


All times are GMT +1. The time now is 01:58 AM.

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

About Us

"It's about Microsoft Excel"