Results 1 to 3 of 3

Thread: Insert rows using a variable

  1. #1

    Thread Starter
    Member
    Join Date
    May 2004
    Location
    Where i am
    Posts
    38

    Insert rows using a variable

    When you insert rows in excel you need to tell excel which row you can't just do
    Rows.Insert Shift:= xlDown
    so i made a variable called linenumber which keeps track of the row number but then i can't seem to make it insert a row by reffering to the variable

    eg

    Rows(linenumber).insert shift:= xldown

    could someone help.plz

  2. #2
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,657

    Re: Insert rows using a variable

    Actually you can just insert a row by "Rows.Insert Shift:= xlDown" but this will just insert the row wherever the cursor happens to be at the moment !

    What you need is to tell Excel where you won't to insert the row aswell

    VB Code:
    1. dim ARow as string
    2.  
    3. ARow  = "6"              ' Row Number here
    4. Rows(ARow).Select    ' Select the Row
    5. Rows.Insert Shift:= xlDown   ' Insert the Row

  3. #3

    Thread Starter
    Member
    Join Date
    May 2004
    Location
    Where i am
    Posts
    38

    Re: Insert rows using a variable

    is there someway to insert a row where the the active cell is?
    Last edited by machinist; Jan 6th, 2005 at 04:16 PM. Reason: mistypes

Posting Permissions

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



Click Here to Expand Forum to Full Width