Look for certain text and paste a phrase in new row for each cell containing that text

iceman4177

New Member
Joined
Aug 8, 2017
Messages
1
So I'm looking for a very simple script that will search for the specific word "proceed" in every cell of column D and paste the phrase "completed and verified" in a new row below the existing text in those cells that contain the word "proceed". I'm very new to VBA. Can anyone help me with this?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
iceman4177,

Welcome to the MrExcel forum.

Here is a macro solution for you to consider that will run in the active worksheet.

If you want to have the macro run in a specific worksheet, then, what is that worksheet name?


Sample raw data in the active worksheet in column D:

Title D
So
I'm
looking
proceed
for
a
simple
script
that
will
search
for
the
specific
word
proceed
Can
anyone
help
me
with
this


And, after the macro:

Title D
So
I'm
looking
proceed
completed and verified
for
a
simple
script
that
will
search
for
the
specific
word
proceed
completed and verified
Can
anyone
help
me
with
this



Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Sub iceman4177()
' hiker95, 08/08/2017, ME1018988
Application.ScreenUpdating = False
Dim r As Long, lr As Long
With ActiveSheet
  lr = .Cells(Rows.Count, "D").End(xlUp).Row
  For r = lr To 2 Step -1
    If .Cells(r, 4) = "proceed" Then
      .Rows(r + 1).Insert
      .Cells(r + 1, 4).Value = "completed and verified"
    End If
  Next r
  .Columns("D:D").AutoFit
End With
Application.ScreenUpdating = True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

Then run the iceman4177 macro.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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