View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
david mcritchie david mcritchie is offline
external usenet poster
 
Posts: 691
Default Inserting row based on value in cell in Column C

Tom gave you a complete macro that includes what I said,
what you see in the thread in chronological order is not necessarily
the order that it "should be read" [or even ignored for something more complete].

There were a couple of typos
(if it were my code they'd be errors and I'd say typos)

Sub InsertRows()
Dim lastRow As Long, cell As Range
'Tom Ogilvy, 2005-03-09 programming --corrected
Dim i As Long
lastRow = Cells(Rows.Count, "C").End(xlUp).row + 1
For i = lastRow To 2 Step -1
Set cell = Cells(i, "C")
If IsNumeric(cell(0, 1).Value) Then '-- correction
If cell(0, 1).Value = 1 Then
cell.Resize(cell(0, 1).Value) _
.EntireRow.Insert
End If
End If
Next i '--correction
End Sub
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm


"Anonymous Chief" wrote...
I tried Tom's solution, but it also does not run, prompts me to debug. Guys,
you have to know that I am not that familiar with creating macros. I can
only insert the code in the visual basic editor and run it, but am nt
capable of debugging it. Tom and Richard have been great, but it still does
not work. I don't know if it will help. I am using Excel 2003. Please help
me, and thank you all for your input. I guess if smeone could try out
somthing based on David McRitchie's suggestion.