View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default A macro solution - replace text given the values

Hi,

Nothing is missing that i'm aware of. It simply loops through every cell in
the used range and if the cell contains a value it does a vlookup of that
value on the temp sheet. If it finds a match it populates that value in the
cell and if it doesn't it resumes next because of the error generated. The
only potential problem I can see is this line has line wrapped when posted
and is really a single line.

c.Value = WorksheetFunction.VLookup(c.Value, Sheets("Temp").Range("A1:B4"),
2, False)


What problem are you getting?


Mike

"Sinner" wrote:

On Sep 9, 4:09 pm, Mike H wrote:
Hi,

Right click sheet 1 tab, view code and paste this in and run it

Sub standard()
For Each c In ActiveSheet.UsedRange
On Error Resume Next
If Not IsEmpty(c) Then
c.Value = WorksheetFunction.VLookup(c.Value, Sheets("Temp").Range("A1:B4"),
2, False)
End If
Next
End Sub

Mike



"Sinner" wrote:
Hi,


I would like to have a macro to replace text in a sheet based on
values in another sheet.


Sample file is at:
http://www.savefile.com/files/1777260


Thx.- Hide quoted text -


- Show quoted text -


Thx bob & mike : )

Mike can u go through your code once again. It seems something is
missing.

Thx.