Knockoutpie
Board Regular
- Joined
- Sep 10, 2018
- Messages
- 116
- Office Version
- 365
- Platform
- Windows
Hi, the below code grabs the value from A2 which starts with "$" and replaces all values on the sheet with an input box.
The only issue is after find and replace it changes cell A2 to currency format because it starts with a $ and removes the $. Is there any way to avoid this?
The only issue is after find and replace it changes cell A2 to currency format because it starts with a $ and removes the $. Is there any way to avoid this?
VBA Code:
Private Sub CommandButton1_Click()
Dim strInput As String
strInput = InputBox("Enter replacement value", Default:="$")
If strInput <> "" Then
Range("A2").Select
Cells.Replace What:=Range("A2"), Replacement:=strInput, LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False, _
FormulaVersion:=xlReplaceFormula2
End If
End Sub