I have this code provided by @mehidy1437 (thank you) that I have been using.
Is it possible to auto-add lines when the group of numbers change?
I don't know if I'm explaining it right.
See example below.
Is it possible to auto-add lines when the group of numbers change?
I don't know if I'm explaining it right.
See example below.
Example |
1111 |
1111 |
(insert blank Line |
2222 |
2222 |
(insert blank Line |
3333 |
3333 |
3333 |
(insert blank Line |
VBA Code:
Sub InsertAlternateRows()
'vba run or not confirmation
Dim Msg As String, Ans As Variant
Msg = "This will insert blank row after a selected no# of row, row no will be given by the user."
Ans = MsgBox(Msg, vbYesNo)
Select Case Ans
Case vbYes
'vba run or not confirmation
'This code will insert a row after every row in the selection
'https://trumpexcel.com/insert-blank-row-after-every-row/
Dim Rng As Range
Dim CountRow As Integer
Dim i As Integer
Dim e As Integer
Dim f As Integer
e = InputBox("Enter number, you will have a blank row after every 'given no#' row", "Input Required")
f = e + 1
Set Rng = Selection
CountRow = Rng.EntireRow.count
'For i = 1 To CountRow
'ActiveCell.EntireRow.Insert
'ActiveCell.Offset(3, 0).Select
'For i = 1 To CountRow / 2
'ActiveCell.Offset(2, 0).EntireRow.Insert
'ActiveCell.Offset(3, 0).Select
'For i = 1 To CountRow / 3
For i = 1 To CountRow / e
ActiveCell.Offset(e, 0).EntireRow.Insert
ActiveCell.Offset(f, 0).Select
Next i
'vba run or not confirmation
Case vbNo
GoTo Quit:
End Select
Quit:
'vba run or not confirmation
End Sub
Last edited by a moderator: