Equate numbers to text

  • Thread starter Thread starter hpum
  • Start date Start date
H

hpum

What is the correct feature and term used to change a value of non-contiguous
cells all at once. I would like to equate a particular number to a name
(text) and have excel automatically lookup all those numbers in the workbook
and change.
 
Let's say we have a pile of cells that contain 3.14 and we wish to change all
of them at once. First run this macro:

Sub mersion()
Set r = Nothing
For Each rr In ActiveSheet.UsedRange
v = rr.Value
If v = 3.14 Then
If r Is Nothing Then
Set r = rr
Else
Set r = Union(r, rr)
End If
End If
Next
r.Select
End Sub

This will Select all cells with the value 3.14.

Next in the formula bar enter:
3.1415926 and touch CNTRL-ENTER rather than just ENTER

This changes all the cells at once. Two comments:

1. you can assign a Named Range to the pile after running the macro
2. consider using only a single cell for common values
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top