Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Insert # of Rows determined by cell

I think I would have kept that check to make sure that the number was always
positive.

If you wanted a little more info (might be helpful if there's another problem):

If IsNumeric(HowMany) Then
If HowMany 1 Then
.Rows(iRow + 1).Resize(HowMany).Insert
Else
msgbox "Row: " & irow & " has a non-positive number"
End If
Else
msgbox "Row: " & iRow & " has nonnumeric data"
End If

Justin H wrote:

We got it! I searched back through the data page by page and found a lone
wolf throwing everything off. One of the rows decided it wanted to have a -9
thrown in there instead of 9. Thanks a ton for you help!

Here is the Final Code Used to get the job done.

Option Explicit
Sub testme()
Dim wks As Worksheet
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim HowMany As Variant

Set wks = Worksheets("sheet1")
With wks
FirstRow = 2 'if there headers in row 1, if not use 1 instead of 2???
LastRow = .Cells(.Rows.Count, "G").End(xlUp).Row

For iRow = LastRow To FirstRow Step -1
HowMany = .Cells(iRow, "G").Value
If IsNumeric(HowMany) Then
.Rows(iRow + 1).Resize(HowMany).Insert
End If
Next iRow
End With
End Sub

It's amazing how things work when the data doesn't play games with you.
Thanks again to everyone who helped out.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find DMIN in a column range determined by a number in another cell dlbeiler Excel Worksheet Functions 0 October 11th 07 07:09 PM
How do I restrict cell entries that are determined by a previous l Gruntos Excel Discussion (Misc queries) 1 August 22nd 07 10:08 AM
how do i insert rows in a cell Julia Excel Worksheet Functions 1 November 20th 06 10:15 AM
Getting a value from a cell that is determined by a formula carl43m Excel Discussion (Misc queries) 3 August 14th 06 06:31 PM
How do I generate a sum, determined by cell color? KFX Excel Worksheet Functions 3 January 2nd 05 12:36 PM


All times are GMT +1. The time now is 05:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"