VBA Select Range and Move based on conditions

Giggs1991

Board Regular
Joined
Mar 17, 2019
Messages
50
Hi All,

I am looking for some help on VBA to Select Range and Move based on conditions.

I would like to move all the contents between "Project A" and "Project B" one column to the right. Same with all contents between Project B and end of table which will also move 1 column to the right.

This is how the table looks now:

Column A Column B Column C
Project A
1/1/2019 Jack 5
2/1/2019 Ryan 8
7/1/2019 James 10
Project B
1/1/2019 Jack 5
2/1/2019 Ryan 8
7/1/2019 James 10
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Try this. Assumes code begins in A1.

Code:
Sub MOVEIT()
With Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row).Offset(, 1)
    .FormulaR1C1 = "=IF(ISERROR(FIND(""Project"",RC[-1])),RC[-1],"""")"
    .Value = .Value
    .SpecialCells(xlCellTypeConstants).Offset(, -1).ClearContents
End With
End Sub
 
Upvote 0
Another option
Code:
Sub Giggs1991()
    Range("A:A").SpecialCells(xlConstants, xlNumbers).Insert xlToRight
End Sub
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,217
Members
452,619
Latest member
Shiv1198

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