+ Reply to Thread
Results 1 to 10 of 10

Increment Row Numbers

  1. #1
    Registered User
    Join Date
    11-19-2014
    Location
    Midlands
    MS-Off Ver
    2010
    Posts
    9

    Increment Row Numbers

    Hi,

    I'm a noob with VBA so i could do with some help. I have created a survey and once the user clicks submit the values will be copied across to a table. All i have so far is the table headers. I need a macro that once clicked, it will look at the current row number in the A column, if the row number has a value, it will take that value and +1 in the next row. If there aren't any rows yet, it will need to start the first row as 1.

    Could anyone help please?

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Increment Row Numbers

    Can you prepare a short sample of you file to see how to manage the data.
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    11-19-2014
    Location
    Midlands
    MS-Off Ver
    2010
    Posts
    9

    Re: Increment Row Numbers

    Quote Originally Posted by PCI View Post
    Can you prepare a short sample of you file to see how to manage the data.
    It's just a small survey that uses combo boxes/option buttons. Once the survey has been completed, it gets transferred to a results page which keeps a tally of the results in the survey using cell link.

    I just need to know to create an incrementing row number everytime the submit button is clicked.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Increment Row Numbers

    This will increment, however it starts at row 2.

    Please Login or Register  to view this content.
    Hope that helps.

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Increment Row Numbers

    See how to have the next availble row
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-19-2014
    Location
    Midlands
    MS-Off Ver
    2010
    Posts
    9

    Re: Increment Row Numbers

    Quote Originally Posted by PCI View Post
    Can you prepare a short sample of you file to see how to manage the data.
    It's just a small survey that uses combo boxes/option buttons. Once the survey has been completed, it gets transferred to a results page which keeps a tally of the results in the survey using cell link.

    I just need to know to create an incrementing row number everytime the submit button is clicked.

  7. #7
    Registered User
    Join Date
    11-19-2014
    Location
    Midlands
    MS-Off Ver
    2010
    Posts
    9

    Re: Increment Row Numbers

    This is the type of thing i want it to do in pseudo-ish terms lol.

    If A2 <> 1
    Make A2 = 1
    Else
    Get next empty cell
    Empty cell = previous cell + 1
    Last edited by Craigr; 11-19-2014 at 11:41 AM.

  8. #8
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Increment Row Numbers

    OK try

    Please Login or Register  to view this content.
    if you want to start at row1 with value 1

    Please Login or Register  to view this content.
    Last edited by PCI; 11-19-2014 at 11:50 AM.

  9. #9
    Registered User
    Join Date
    11-19-2014
    Location
    Midlands
    MS-Off Ver
    2010
    Posts
    9

    Re: Increment Row Numbers

    Quote Originally Posted by PCI View Post
    OK try

    Please Login or Register  to view this content.
    if you want to start at row1 with value 1

    Please Login or Register  to view this content.
    Edit - Thanks, that works!
    Last edited by Craigr; 11-19-2014 at 11:56 AM.

  10. #10
    Registered User
    Join Date
    12-15-2014
    Location
    India
    MS-Off Ver
    2010
    Posts
    1

    Re: Increment Row Numbers

    I have created a survey and once the user clicks submit the values will be copied across to a table. I have a macro that once clicked, it will look at the current row number in the C column, if the row number has a value, it will take that value and +1 in the next row. If there aren't any rows yet, it will need to start the first row as 1.
    But I wanted to have another code, which will create a row number along with a specific format. For example, if some one submit the value, it should create an ID some thing like ABC001 or ABC002...etc. How should I edit my code. I am attaching my code below.

    Option Explicit

    Sub StartNewRecord()
    Dim inputWks As Worksheet
    Dim listWks As Worksheet
    Dim rngClear As Range
    Dim rngNext As Range
    Dim rngID As Range

    Set inputWks = Worksheets("Input")
    Set listWks = Worksheets("LookupLists")

    Set rngClear = inputWks.Range("DataEntryClear")
    Set rngID = inputWks.Range("IDNum")
    Set rngNext = listWks.Range("NextID")

    rngClear.ClearContents
    rngID.Value = rngNext.Value

    inputWks.Activate
    rngID.Offset(1, 0).Activate

    End Sub
    Last edited by siby.cb; 12-15-2014 at 07:52 AM. Reason: wrong code

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] increment numbers
    By grkchakri in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-11-2014, 10:00 AM
  2. increment numbers by 1 when saving to folder
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-08-2013, 05:50 PM
  3. Getting Excel to NOT increment numbers in column
    By without_sanity in forum Excel General
    Replies: 2
    Last Post: 05-24-2010, 03:13 PM
  4. Increment Numbers
    By Tashia in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-04-2008, 02:00 PM
  5. round UP numbers in half increment.
    By dannyboy213 in forum Excel General
    Replies: 1
    Last Post: 08-30-2006, 04:26 PM

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