View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Karti[_2_] Karti[_2_] is offline
external usenet poster
 
Posts: 3
Default Insert rows

Sorry for posting, found the answer
rows(value1 & ":" & value2).insert shift:=xlDown

"Karti" wrote in message
...
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