VBA: Insert rows

K

Karti

Hi,
I am using the following VBA code to insert a number of rows starting from
the value contained in cells(5,3) and ends before or on cells(10,3) the
values are always in ascending order and in series. like 12, 13,1 4 etc. I
am getting a type mismatch error in the last line of code. It will be great
if someone can help me out with this.

Sub main()
Dim i As Integer
Dim value1 As Integer
Dim value2 As Integer
value1 = Cells(5, 3).Value
For i = 1 To 5
If Cells(5 + i, 3) <> "" Then
value2 = Cells(5 + i, 3).Value
'MsgBox value2
End If
Next i
'MsgBox value2
Rows("value1:value2").Insert shift:=xlDown


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top