Colin said:
Hi
OK thanks - this worked perfectly first time and precisely fits the
bill. I'm impressed.
I did find that on the second popup (Minimum value found was ..Enter
value to replace..) that if I click 'cancel' then all of the selected
values from the first popup are wiped form the worksheet , leaving blank
cells. I imagined it would just exit the routine with no further action
or impact.
Anyway , thanks again.
Best Wishes
Colin
My bad! That would be the one thing I did not test. Not very good
programming, is it? (^: Try this replacement:
Sub ReplaceIt2()
Dim TheColumn As Variant
Dim TheRange As String
Dim TheMin As Variant
Dim TheNewValue As Variant
Dim OriginalRange As String
Dim OriginalCell As String
On Error GoTo Quitter
Application.ScreenUpdating = False
OriginalRange = Selection.Address
OriginalCell = ActiveCell.Address
TheColumn = InputBox("Which column?")
If TheColumn <> "" Then
TheRange = TheColumn & ":" & TheColumn
TheMin = Application.WorksheetFunction. _
Min(Range(TheRange))
TheNewValue = InputBox("Minimum value found was " & _
TheMin & ". Enter value to replace.")
If TheNewValue <> "" Then
Range(TheRange).Select
Selection.Replace What:=TheMin, _
Replacement:=TheNewValue, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=False, _
SearchFormat:=False, _
ReplaceFormat:=False
Else
MsgBox "No input, operation canceled."
End If
Range(OriginalRange).Select
Range(OriginalCell).Activate
Else
MsgBox "No input, quitting."
End If
Quitter:
Application.ScreenUpdating = True
End Sub