Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Excel VBA - insert blank row and format it
#1
VBA sample code to insert a new ro in excel and format the new row

Code reference : stackoverflow

Code:
Sub Insert_Blank_Rows()
    Dim iRow As Long
    Dim myText As String

    myText = Range("E5").Text
    With Selection
        For iRow = .Rows.Count To 1 Step -1
            .Rows(iRow + 1).EntireRow.Insert shift:=xlDown
            With .Rows(iRow + 1)
                .Range("A1:B1").Value = .Offset(-1).Range("A1:B1").Value
                .Range("C1:D1").Value = Array("No Show", myText)
            End With
        Next
    End With
End Sub

[Image: Screenshot_2020-02-12%2BNew%2BThread%2Bi...%2BVBA.png]
Reply
#1
VBA sample code to insert a new ro in excel and format the new row

Code reference : stackoverflow

Code:
Sub Insert_Blank_Rows()
    Dim iRow As Long
    Dim myText As String

    myText = Range("E5").Text
    With Selection
        For iRow = .Rows.Count To 1 Step -1
            .Rows(iRow + 1).EntireRow.Insert shift:=xlDown
            With .Rows(iRow + 1)
                .Range("A1:B1").Value = .Offset(-1).Range("A1:B1").Value
                .Range("C1:D1").Value = Array("No Show", myText)
            End With
        Next
    End With
End Sub

[Image: Screenshot_2020-02-12%2BNew%2BThread%2Bi...%2BVBA.png]
Reply
CAA


Messages In This Thread
Excel VBA - insert blank row and format it - by techberth - 12-02-2020, 03:59 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)