Shifting cell down with formula

kamranyd

Board Regular
Joined
Apr 24, 2018
Messages
152
Office Version
  1. 2021
Platform
  1. Windows
these codes shift one cell down, whereas i want first 3 cells shift down and fill, rest cells shift down but don't fill, and can we make these codes more short?

VBA Code:
Private Sub add_row_list_Click()
With Selection
        ActiveCell.Offset(1).Resize(1, 9).Insert shift:=xlDown
        ActiveCell.Offset(1, 1).FillDown
        ActiveCell.Offset(1, 2).FillDown
        ActiveCell.Offset(1, 3).FillDown
        ActiveCell.Offset(1, 4).FillDown
        ActiveCell.Offset(1, 5).FillDown
        ActiveCell.Offset(1, 6).FillDown
        ActiveCell.Offset(1, 7).FillDown
        ActiveCell.Offset(1, 8).FillDown
        ActiveCell.Offset(1, 0).Select
End With
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
How about this?
VBA Code:
Private Sub add_row_list_Click()
    With Selection
        .Offset(1).Resize(1, 9).Insert shift:=xlDown
        .Offset(1, 1).Resize(, 8).FillDown
        .Offset(1, 0).Select
    End With
End Sub
 
Upvote 0
Solution
Maybe something like this.

VBA Code:
Private Sub add_row_list_Click()
    With Selection
        With ActiveCell.Offset(1).Resize(1, 9)
            .Insert shift:=xlDown
            .Offset(-1, 0).FillDown
            .Resize(2).Insert shift:=xlDown
        End With
        ActiveCell.Offset(1, 0).Select
    End With
End Sub
 
Upvote 0
How about this?
VBA Code:
Private Sub add_row_list_Click()
    With Selection
        .Offset(1).Resize(1, 9).Insert shift:=xlDown
        .Offset(1, 1).Resize(, 8).FillDown
        .Offset(1, 0).Select
    End With
End Sub
thnx
 
Upvote 0
Maybe something like this.

VBA Code:
Private Sub add_row_list_Click()
    With Selection
        With ActiveCell.Offset(1).Resize(1, 9)
            .Insert shift:=xlDown
            .Offset(-1, 0).FillDown
            .Resize(2).Insert shift:=xlDown
        End With
        ActiveCell.Offset(1, 0).Select
    End With
End Sub
thanx i can use these codes somewhere else, but for now Mr. Cubist codes work for me.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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