View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Sinner Sinner is offline
external usenet poster
 
Posts: 142
Default A macro solution - replace text given the values

On Sep 9, 6:37*pm, Mike H wrote:
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.- Hide quoted text -


- Show quoted text -


Dear Mike,

Both are wokring but now the problem is that I have a lot of data &
it's taking too much time. Vlooup calculation time is wayyyy too long.
Find/Replace is much faster but can we get it through VB?

Thx.