Insert a new row and fill it with data in VBA - Printable Version +- QP School (https://qomplainerzschool.lima-city.de) +-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3) +--- Forum: Excel VBA Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=48) +--- Thread: Insert a new row and fill it with data in VBA (/showthread.php?tid=5252) |
Insert a new row and fill it with data in VBA - Qomplainerz - 07-27-2023 Example: Sub InsertAndFillRow() Rows(2).Insert Shift:=xlDown Range("A2").Value = "John" Range("B2").Value = 25 Range("C2").Value = "Sales" End Sub Explanation: The code defines a subroutine named InsertAndFillRow. Rows(2).Insert Shift:=xlDown inserts a new row at the second row and shifts the existing rows down to make space for the new row. Range("A2").Value = "John" sets the value "John" in cell A2. Range("B2").Value = 25 sets the value 25 in cell B2. Range("C2").Value = "Sales" sets the value "Sales" in cell C2. |