Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Inserting #of rows based on dcount

  1. #11
    Board Regular
    Join Date
    Apr 2002
    Location
    Indianapolis
    Posts
    80
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Nate -

    I missed your location on that last post. I'm in the other "polis"... Indianapolis. My brother lives up your way in Lakeville,MN.

    Thanks again for all of your help


  2. #12
    MrExcel MVP Jay Petrulis's Avatar
    Join Date
    Mar 2002
    Location
    Chicago, IL USA
    Posts
    2,040
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-30 10:48, NateO wrote:
    I think I've botched the question. Do you mean 'insert91' is a single cell and instead of inserting single cells, you want a row. Try:

    Code:
    Sub addb600()
    Dim i As Long, n As Long
    i = Sheets("information").Range("bcount").Value
    For n = 1 To i
    Sheets("Detail").Range("insert91").EntireRow.Insert
    Next n
    
    End Sub
    Getting warmer?

    _________________
    Cheers, NateO

    [ This Message was edited by: NateO on 2002-04-30 10:49 ]
    Greetings from another midwesterner.

    To make the working code even more efficient, remove the i = 1 to n loop and insert all the rows in one shot.

    Sub addb600()
    Dim i As Long, i2 As Long

    i = Sheets("information").Range("bcount").Value
    i2 = Sheets("Detail").Range("insert91").Row
    Rows(i2).Resize(i).Insert

    End Sub

    Untested, but should work. (I am assuming you've activated the correct sheet.)

    Bye,
    Jay

    EDIT: If the number of rows is small, this won't save any time that could be noticed. I just wanted to pass along the .Resize option, which I've just learned and have found useful.

    [ This Message was edited by: Jay Petrulis on 2002-04-30 11:45 ]

  3. #13
    Board Regular
    Join Date
    Apr 2002
    Location
    Indianapolis
    Posts
    80
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks, Jay for the code. I'll give it a try ... probably next week when I try to clean up after myself... right now I'm just trying to get this application to work for month end.

    Lisa

  4. #14
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I took the liberty, it works. Faster than the loop, which as Jay mentioned, is nicer in the scheme of large procedures.

    _________________
    Cheers, NateO

    [ This Message was edited by: NateO on 2002-04-30 12:43 ]

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •