Change Test of Cell based on Value in VBA

Jones1413

New Member
Joined
Jul 26, 2019
Messages
47
Office Version
  1. 365
Platform
  1. Windows
Hello,

I need to write a VBA macro that will change the text of a cell based on the value already in the cell. For example, the cell can be anywhere in Column A and if the cell value equals "Jones1413" I want to change the text of that cell to "BJones". The rows of data can change and the value will not be in the same cell every time the report is ran.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I think we need some more details, such as:
1. Where is the "key" that tells us what we are looking for, and what we want to change it to?
2. How is this VBA code to be run? Are you going to do it manually, or do you want it to happen automatically?
If automatically, what "action" should trigger the code to run?
 
Upvote 0
This example describes simple find word and replace...
VBA Code:
Private Sub ReplaceWord()

    Dim vInput1 As String, vInput2 As String, vNR As Long, vF As Range
    
    vInput1 = InputBox("Input word to find")
    vInput2 = InputBox("Replace word with...")
    vNR = Cells(Rows.Count, "A").End(xlUp).Row
    Set vF = Range("A1:A" & vNR).Find(vInput1)
    If Not vF Is Nothing Then
        Range("A" & vF.Row) = vInput2
    End If
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,666
Members
448,977
Latest member
moonlight6

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top