PDA

Click to See Complete Forum and Search --> : Insert as many rows as it says in cell c18


taosd
Jul 31st, 2003, 10:58 AM
I have a macro currently that inserts rows based on values. I want to be able to have it look at cell c18 then insert that many rows starting at the first blank that it finds.

so, if it finds the first blank at h27 on the "DATA" spreadsheet, and c18 says 4, I want it to insert 4 rows starting at H27...

it will always be referencing the data sheet, it is not workbook wide. I assume this is possible... and probably not difficult, but i do not know much about visual basic.

j_jewell
Aug 1st, 2003, 03:06 PM
Dim yRow As Integer
Dim intInserts As Integer

yRow = 1
intInserts = CInt(Application.Range("C18"))
Do Until Len(Trim(Application.Cells(yRow, 1))) = 0
yRow = yRow + 1
Loop

For i = 1 To intInserts
Rows(yRow & ":" & yRow).Select
Selection.Insert Shift:=xlDown
Next


I don't know if this is exactly what you want...but it's on the right track, I think.

taosd
Aug 1st, 2003, 03:12 PM
Originally posted by j_jewell

Dim yRow As Integer
Dim intInserts As Integer

yRow = 1
intInserts = CInt(Application.Range("C18"))
Do Until Len(Trim(Application.Cells(yRow, 1))) = 0
yRow = yRow + 1
Loop

For i = 1 To intInserts
Rows(yRow & ":" & yRow).Select
Selection.Insert Shift:=xlDown
Next


I don't know if this is exactly what you want...but it's on the right track, I think.

wow.. that kicks much a$$... thank you so much...!