button to insert 4 cells and move current data to the left or down

ohmedic88

Board Regular
Joined
Jun 24, 2013
Messages
124
How do I build a button to insert cells. Currently I have a sheet that I keep adding data to the left and it is getting out of hand. So I want to add a button to insert blank cells and push all the older data to the left. This way the newest data can be easily accessed and visible.

In this example I need to added new information in c3, c4, c5, c6 and all the existing data moved to c7,c8,c9,c10 and so on and so forth. I need to be able to add cells to any of the rows (Eric, Ron, Steve etc)

Also how hard is it to do the same to add cells that move down?

Thanks in advance.

NameOriginal start dateOriginal
Stop Date
CompletenameStartStopCompletenameStartStopCompletenamestart
Ericxx/xx/xxxx/xx/xxyesEricxx/xx/xxxx/xx/xxno
Ronxx/xx/xxxx/xx/xxyesInsertedInsertedInsertedInsertedolder dataolder dataolder dataolder data
Stevexx/xx/xxxx/xx/xxno
Cathyxx/xx/xxxx/xx/xxyes
Jessiexx/xx/xxno
Darlaxx/xx/xxno

<tbody>
</tbody>
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
The 1st sub will shift the adjacent selected cells in a single column 4 columns to the right.
The 2nd sub will shift the adjacent selected cells in a single row 4 rows down.

Code:
Option Explicit


Sub Insert4CellsToRightOfSelection()
    
    Dim rng As Range
    Set rng = Selection
    
    If rng.Columns.Count > 1 Or rng.Areas.Count > 1 Then
        MsgBox "Select one or more adjacent cells in a single column"
        GoTo End_Sub
    End If
    
    Range(Selection, Selection.Offset(0, 3)).Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
End_Sub:
End Sub
Sub Insert4CellsBelowSelection()
    
    Dim rng As Range
    Set rng = Selection
    
    If rng.Rows.Count > 1 Or rng.Areas.Count > 1 Then
        MsgBox "Select one or more adjacent cells in a single row"
        GoTo End_Sub
    End If
    
    Range(Selection, Selection.Offset(3, 0)).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End_Sub:
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,744
Messages
6,057,116
Members
444,905
Latest member
Iamtryingman

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