Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
insert rows and copying cells in column b,c, and d into new rows | Excel Programming | |||
VBA to count rows from specific cell and insert rows | Excel Programming | |||
Insert rows: Formats & formulas extended to additonal rows | Excel Worksheet Functions | |||
Insert page breaks every 50 rows but do not include hidden rows | Excel Programming | |||
Copy Rows and insert these rows before a page break | Excel Programming |