+ Reply to Thread
Results 1 to 11 of 11

How to implement Customer ID auto increment when using alpha numeric values with VBA

  1. #1
    Registered User
    Join Date
    02-08-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    22

    How to implement Customer ID auto increment when using alpha numeric values with VBA

    I have created a simple UserForm to enter new customer details to the Customer List in the spreadsheet, form works fine except for one little thing, which is New Customer ID, which works, but only with numeric values like 1, 2, 3 and so on.

    Basically what I need this for to do is once form is opened/called new customer ID need to be created, which could be and Alfa numerical set of characters like AA-01234, AA-01235, AA-01236 and so on.

    Also, is there a way of posting newly added Customer ID in the MsgBox along with MsgBox "One record added to Customers List. New Customer ID is "

    All of my attempts to create this are failing and causing errors, which I really cannot figure out since I am new to VBA and had never used it until now.

    Please help me a little.

    Here is my code, Customer ID is TextBox1.

    Thanks in advance
    Please Login or Register  to view this content.
    If my spreadsheet is required, please let me know and I can post it here

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: How to implement Customer ID auto increment when using alpha numeric values with VBA

    Try something like this. You can decide how to best integrate it with your existing code.

    Please Login or Register  to view this content.
    Also note: it's not good practice to close a userform with the End command. That will abruptly quit all VBA code execution and could cause unexpected consequences. It's more common to use Unload Me instead.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    02-08-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    22

    Re: How to implement Customer ID auto increment when using alpha numeric values with VBA

    @AlphaFrog, thanks for your suggestion about "Unload Me", it is always good to learn something new.

    The firs part part of the code did not work at all, possible reason is that I might have done something that I should not have.

    If it is not too much can you please post entire code as it should be?

    Thanks in advance.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: How to implement Customer ID auto increment when using alpha numeric values with VBA

    That is a lot to ask and I'm a bit lazy. I don't want to have to build my own userform and data sheet and then guess if it's like yours. Can you post an example workbook? Help me help you.

    Also; your ID naming convention (TAS1) in the UserForm_Activate procedure doesn't match your description (AA-12345); explain?

    It's a given if it didn't work, one of us did something wrong. Just saying it doesn't work without explanation of what you tried and what then happened doesn't help me diagnose the problem. It may be something as simple as a misspelled or misplaced command. You really need to be much more verbose. Take the time to fully describe what you want, what you tried, and what was the result of the attempt.

  5. #5
    Registered User
    Join Date
    02-08-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    22

    Re: How to implement Customer ID auto increment when using alpha numeric values with VBA

    I've posted code that I was trying at that point of time by accident. Here I am posting another version of the code and Image of the Customer DB where Data posted via UserForm is stored.

    Please Login or Register  to view this content.
    Attached Images Attached Images

  6. #6
    Registered User
    Join Date
    02-08-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    22

    Re: How to implement Customer ID auto increment when using alpha numeric values with VBA

    No matter how many times I try to enter a new customer details ID remains the same when realistically it should change every time, I cannot figure out what I am doing wrong. Please help and thanks for being patient

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: How to implement Customer ID auto increment when using alpha numeric values with VBA

    Replace this...
    Please Login or Register  to view this content.
    With what I suggested.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    02-08-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    22

    Re: How to implement Customer ID auto increment when using alpha numeric values with VBA

    I have done so but it did not work, I ended with and Error

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: How to implement Customer ID auto increment when using alpha numeric values with VBA

    Try
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    02-08-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    22

    Re: How to implement Customer ID auto increment when using alpha numeric values with VBA

    Sweet, works like magic, but little too slow, otherwise perfect

    Thanks a lot and once again thank for being patient!!

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: How to implement Customer ID auto increment when using alpha numeric values with VBA

    Quote Originally Posted by Alexb77 View Post
    Sweet, works like magic, but little too slow, otherwise perfect
    Are you talking about the code I posted?

    I have tested the code for myself with 47000 rows of data and took only 0.109375 sec.

    It must be other part of your 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. Replies: 9
    Last Post: 11-18-2013, 07:40 AM
  2. Macro to delete alpha and alpha numeric values
    By vijanand1279 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2011, 09:13 AM
  3. Extracting Numeric Values from an Alpha/Numeric String
    By Delkath in forum Excel General
    Replies: 5
    Last Post: 10-27-2010, 02:36 PM
  4. Increment Alpha Numeric Cell
    By Theresa in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-08-2006, 02:45 PM
  5. [SOLVED] Increment Alpha Numeric Cell
    By Theresa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-06-2006, 05:40 PM

Tags for this Thread

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