You are on page 1of 2

Sub insertrow()

' Macro for inserting row


' Make sure you save your work before you test this,
' but if you place your cursor at the start of the column
' you wish to check for data, this code will insert one row
' each time a non-blank cell is encountered. The code will
' only run for the first 20 rows of data.
Application.ScreenUpdating = True
Dim count As Integer
Dim X As Integer
For count = 1 To 20
If activecell.Value <> "" Then
activecell.Offset(1, 0).Select
Range(activecell, activecell.Offset(0, 0)).EntireRow.Insert
activecell.Offset(1, 0).Select
For X = 1 To 1
Next X
Else
activecell.Offset(1, 0).Range("a1").Select
End If
Next count
End Sub
********************************************************************************
*
Sub yCopyReceiptNumberOfTimesInCellA1BelowReceipt()
' kopira sadraj elije A1 10 puta
Cnt = [10]
With Range("A1")
rws = .Rows.Count
.Copy .Offset(rws).Resize(rws * Cnt)
End With
End Sub
********************************************************************************
**
Sub test()
'kopiranje redova n puta svaki red tri puta
Dim n As Integer, rng As Range
n = InputBox("type the value of n")
Set rng = Range("a1")
rng.Select
line2:
Range(rng.Offset(1, 0), rng.Offset(3, 0)).EntireRow.Insert
Range(rng, rng.End(xlToRight)).Copy
Range(rng, rng.Offset(n, 0)).PasteSpecial
Set rng = rng.Offset(n + 1, 0)
If rng = "" Then
GoTo line1
Else
GoTo line2
End If
line1:
Application.CutCopyMode = False
Range("a1").Select
MsgBox "macro over"
End Sub
*******************************************************************************

You might also like