+ Reply to Thread
Results 1 to 7 of 7

Strange effect trying to insert new line

  1. #1
    Registered User
    Join Date
    02-08-2009
    Location
    Bridgwater, UK
    MS-Off Ver
    Excel 2003
    Posts
    17

    Strange effect trying to insert new line

    I currently have a macro that, when a user clicks on a button, inserts a new line enabling the user to enter further information.

    Now, the problem is that if I click the button to run the macro, or run the macro via the menu, a new line is inserted, but below the one the user is on.

    If I go into VB and 'step' through the macro, then the line is inserted 'above' the one that the user is on which is what I want.

    The macro I am using is;

    Please Login or Register  to view this content.
    It's one of those things that I can't for the life of me work out what's going wrong where.
    Last edited by FoxIII; 02-18-2009 at 10:07 AM.

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,446

    Re: Strange effect trying to insert new line

    Hi,

    The code you've attached will always insert a row at row number 7.

    To insert a row above the row of the currently selected cell, try this.

    Please Login or Register  to view this content.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Registered User
    Join Date
    02-08-2009
    Location
    Bridgwater, UK
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Strange effect trying to insert new line

    I don't think I explained it well enough :s

    When the user clicks 'add new line', a new blank line is inserted at row 7 which moves the current line down to row 8.

    What I have and I tried your code to, just creates a new line after row 7. I can't move one row up and use the code to copy it, as this is the titles and has a different setup.

  4. #4
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,446

    Re: Strange effect trying to insert new line

    What do you want to happen exactly?

    The user clicks a button and it adds a new line below row 7 and moves everything else down? Or it adds a new line where the cell is selected?

  5. #5
    Registered User
    Join Date
    02-08-2009
    Location
    Bridgwater, UK
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Strange effect trying to insert new line

    A user will complete row 7 with the relevant information. When they want a new blank line to complete another row, I want row 7 (the already completed row) to move down a row (to row 8) and a new row to be inserted at row 7.

    The user will then always be inserting their information in row 7 and the previous information will be shifted down. Part of the information is a date, so this will be in descending order.

    Ex.

    Row 7: 01/01/09 Description 1 £30.00

    after clicking on an 'Add New Line' button...

    Row 7: 02/02/09 Description 2 £25.00
    Row 8: 01/01/09 Description 1 £30.00

    I hope I've managed to explain that better this time.

  6. #6
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,446

    Re: Strange effect trying to insert new line

    OK, understood!

    I can't get this:

    Please Login or Register  to view this content.
    to do anything other than insert a blank row at row 7 and move the previous down.

    Please let me know how it works out for you?

  7. #7
    Registered User
    Join Date
    02-08-2009
    Location
    Bridgwater, UK
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Strange effect trying to insert new line

    Yes! Thank you sweep, that works exactly as I wanted :D

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1