Automatically Fill Formula When Inserting Blank Rows With VBA Code

kamranyd

Board Regular
Joined
Apr 24, 2018
Messages
152
Office Version
  1. 2021
Platform
  1. Windows
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Updateby Extendoffice 20160725
    Cancel = True
    Target.Offset(1).EntireRow.Insert
    Target.EntireRow.Copy Target.Offset(1).EntireRow
    On Error Resume Next
    Target.Offset(1).EntireRow.SpecialCells(xlConstants).ClearContents
End Sub

how to make active X or any other simple button of these codes, its in double click mode.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
See here: Assign a macro to a Form or a Control button

You should be able to take the body of your current code and copy/psate it into the VBA code behind the button.
Just change all your "Target" range references to "ActiveCell", and I think that should do what you want (it will run on the ActiveCell).
 
Upvote 0
You are welcome.

If you have any trouble, just post back here with the details.
 
Upvote 0
You are welcome.

If you have any trouble, just post back here with the details.
after adding row it select active row cell, I want after adding row it should select added row cell
 
Upvote 0
If you are adding the new row beneath the activecell, then to select the cell in the new row, you can just use:
VBA Code:
ActiveCell.Offset(1,0).Select

If you wanted to select the entire row, you could use:
VBA Code:
ActiveCell.Offset(1,0).EntireRow.Select
 
Upvote 0
If you are adding the new row beneath the activecell, then to select the cell in the new row, you can just use:
VBA Code:
ActiveCell.Offset(1,0).Select

If you wanted to select the entire row, you could use:
VBA Code:
ActiveCell.Offset(1,0).EntireRow.Select
thnx it work now.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
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