Skip to main content

 How to autofill formula when inserting rows in Excel?

Author: Xiaoyang Last Modified: 2024-08-12

When you insert blank rows between existing data rows, the formula will not copy and paste into the new row, you should drag or fill it manually. But, sometimes, you would like to fill the formula when you insert blank rows between data range automatically as following screenshot shown, this article, I will talk about some quick tricks to solve this task.

dautofill formula when inserting row

Auto fill formula when inserting blank rows with creating a table

Auto fill formula when inserting blank rows with VBA code


Auto fill formula when inserting blank rows with creating a table

In Excel, the Table format can help you to fill the above formula into the new inserted blank rows automatically, please do as follows:

1. Select the data range that you want to auto fill formula, and then click Insert > Table, see screenshot:

click Table form Insert tab

2. In the Create Table dialog, check the My table has headers if there are headers in your data, see screenshot:

set options in the Create Table dialog

3. Then click OK button, and the table has been created, and now, when you insert a blank row, the above formula will be inserted into the new row automatically, see screenshot:

when inserting a blank row, the above formula will be inserted into the new row automatically



Auto fill formula when inserting blank rows with VBA code

If you don’t like to change the data to table, the below VBA code also can help you to achieve this problem.

1. Select the worksheet tab which contains the formulas you want to auto fill, and right click to choose View Code from the context menu to go to the Microsoft Visual Basic for Applications window , and then copy and paste the following code into the Module:

VBA code: Auto fill formula when inserting blank rows

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

click View Code and paste the vba code

2. Then save and close this code, go back to the worksheet, now, when you double click a cell between the data, a new row will be inserted below the active cell and the formula is auto filled as well.


Demo: Auto fill formula when inserting blank rows

 

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!