Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Insert a new row and fill it with data in VBA
#1
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.
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Copy data to another worksheet Qomplainerz 0 401 07-27-2023, 11:24 AM
Last Post: Qomplainerz
  Concatenate data in columns Qomplainerz 0 348 07-27-2023, 11:01 AM
Last Post: Qomplainerz
  Create a pivot table based on data in a worksheet with VBA Qomplainerz 0 415 07-27-2023, 09:48 AM
Last Post: Qomplainerz
  Filter data in a worksheet Qomplainerz 0 383 07-27-2023, 09:46 AM
Last Post: Qomplainerz
  Create a chart from data with VBA Qomplainerz 0 382 07-27-2023, 09:44 AM
Last Post: Qomplainerz
  Sort data in a range with VBA Qomplainerz 0 367 07-27-2023, 09:43 AM
Last Post: Qomplainerz
  Add data validation to a cell with VBA Qomplainerz 0 359 07-27-2023, 09:10 AM
Last Post: Qomplainerz
  Loop to fill numbers in cells with VBA Qomplainerz 0 380 07-27-2023, 08:16 AM
Last Post: Qomplainerz
  Copy data from one workbook to another with VBA Qomplainerz 0 334 07-27-2023, 08:02 AM
Last Post: Qomplainerz
  Pasting data with VBA Qomplainerz 0 287 07-27-2023, 06:33 AM
Last Post: Qomplainerz

Forum Jump:


Users browsing this thread: 2 Guest(s)