+ Reply to Thread
Results 1 to 7 of 7

VBA to increment number not working

  1. #1
    Forum Contributor
    Join Date
    02-08-2006
    Location
    UK
    MS-Off Ver
    2013
    Posts
    204

    VBA to increment number not working

    I'm using a userform to enter data and to insert the data into a sheet as a row. the values in row A are record numbers that increment by 1 each time a row is entered.

    The problem is that while it inserts the new row with the data, the record number only comes in as 1 and I'm banging my head against a brick wall trying to solve it. Cells in row A are formatted as number.

    here's the code (there are more columns but they are not needed to be shown). Hope someone can help / put me out of my misery!

    Please Login or Register  to view this content.
    Last edited by wonderdunder; 05-26-2011 at 07:51 AM.

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: VBA to increment number not working

    Should this line

    Please Login or Register  to view this content.
    be

    Please Login or Register  to view this content.

  3. #3
    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,444

    Re: VBA to increment number not working

    Hi,

    Could you please edit your post and wrap the code in code tags?

    Then, remove the dot from in front of Newrow in the 4th line of code.
    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".

  4. #4
    Forum Contributor
    Join Date
    02-08-2006
    Location
    UK
    MS-Off Ver
    2013
    Posts
    204

    Re: VBA to increment number not working

    Hi, it is without the full stop as in the second part quoted (don't know how that got in there). Sorry for that

  5. #5
    Forum Contributor
    Join Date
    02-08-2006
    Location
    UK
    MS-Off Ver
    2013
    Posts
    204

    Re: VBA to increment number not working

    Tried a little problem solving and I know that this:
    Please Login or Register  to view this content.
    is the problem. I've got it to print in another cell the value without +1 and it comes up as null. All other steps check out OK.

    I've double checked the cell formatting and it is definitely set up as number (0 dp). I've also entered in another cell "=A2+1" and it shows the correct result.

    So for some reason the code I've just referred to is not seeing the value held in the cell above (and it definitely does look at it). I thought it might be the way it is entered so I have manually typed in some values but its still not working. Any ideas why?

  6. #6
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: VBA to increment number not working

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    02-08-2006
    Location
    UK
    MS-Off Ver
    2013
    Posts
    204

    Re: VBA to increment number not working

    That's got it going - thank you!

+ 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