Inserting a cell when it contain specific words and moving original cell to the right

paulc9499

New Member
Joined
May 24, 2017
Messages
10
Hi,

I need to insert a cell and move the original cell to the right but only if the cell contains a specific word.

I have managed to get it to find the cell in the range and highlight the text in bold (which i don't need to do) but are struggling to get it to insert a cell in its place and moving everything to the right.

Any help gratefully received

Many thanks
Paul
 

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.
Code:
Public Sub MoveAdminToRight()

Dim lastRow As Long
Dim thisRow As Long
Const SearchColumn = "A" ' Change this to be the column that needs to be moved
Const SearchText = "admin" ' Change this to be the text we're looking for
Const ColumnCount = 8 ' Change this to be the number of columns to insert

lastRow = Cells(Rows.Count, SearchColumn).End(xlUp).Row

For thisRow = 1 To lastRow
    If Cells(thisRow, SearchColumn).Value = SearchText Then
        Cells(thisRow, SearchColumn).Resize(1, ColumnCount).Insert xlShiftToRight
    End If
Next thisRow

End Sub

WBD
 
Upvote 0

Forum statistics

Threads
1,223,927
Messages
6,175,439
Members
452,641
Latest member
Arcaila

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