+ Reply to Thread
Results 1 to 3 of 3

Vba to generate Reference Number, input box for user to enter 1st Ref

  1. #1
    Forum Contributor
    Join Date
    03-12-2012
    Location
    Singapore
    MS-Off Ver
    MS 365
    Posts
    532

    Vba to generate Reference Number, input box for user to enter 1st Ref

    Hi, i have a data sheet where Column A is the Type, basically there are 3 type. A B C.
    My ref is like this "A20180601" where A is the brand, 201806 is yyyymm and 01 is the number of A.
    Upon clicking a button, I hope to have a inputbox where user can enter the yyyymm and the reference will automatically generate.
    However, the code will prompt a input box, example "Please input the first number for Type A/B/C", when it hit the 1st A/B/C while going down the loop.
    After which, it will continue to generate the Refenence number Until it reach another 1st A/B/C where it will prompt again
    I need the 1st number to be manually input becoz the whole data does not come from 1 excel file and hence the 1st reference number might not be 1.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    06-01-2017
    Location
    VietNam
    MS-Off Ver
    2016
    Posts
    8

    Re: Vba to generate Reference Number, input box for user to enter 1st Ref

    You refer to try
    PHP Code: 
    Option Explicit
    Public Const fYear As Long 1950
    Public Const eYear As Long 2028
        Sub pInput
    ()
        
    Dim Rng_Data As RangetDate As StringeRng As Range
        Dim N 
    As LongAs LongArr(), Txt As String
    On Error 
    GoTo Thoat
    Set Rng_Data 
    Application.InputBox(Prompt:="Select data "Title:="Select the data area"Type:=8)
    tDate Application.InputBox(Prompt:="Type dd/mm/yyyy "Title:="Select dates"Type:=2)
    If 
    IsDate(tDate) = False Then
        MsgBox 
    "Type: dd/mm/yy hoac dd-mm-yy"vbExclamation
    End 
    If
    If 
    Format(tDate"yyyy") < fYear Or Format(tDate"yyyy") > eYear Then
        MsgBox 
    "No this year"vbExclamation
    End 
    If
    If 
    IsDate(tDate) = True Then
        Txt 
    Format(tDate"yyyy") & Format(tDate"mm")
    End If
    If 
    Rng_Data.Columns.Count 1 Then
        ReDim Arr
    (1 To Rng_Data.Rows.Count1 To 1)
        For 
    1 To Rng_Data.Rows.Count
            N 
    Application.CountIf(Range(Rng_Data(1), Rng_Data(I)), Rng_Data(I))
            
    Arr(I1) = Rng_Data(I) & Txt Format(N"0#")
        
    Next I
    End 
    If
    Set eRng Application.InputBox(Prompt:="Select a cell "Title:="Output data"Type:=8)
    eRng.Resize(1) = Arr
    Thoat
    :
    End Sub 

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

    Re: Vba to generate Reference Number, input box for user to enter 1st Ref

    Try
    Please Login or Register  to view this content.
    Last edited by jindon; 06-12-2018 at 11:50 PM.

+ 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] Enter User Input Data into Next Free Cell based on Column Name
    By nKife in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-21-2015, 08:45 PM
  2. Data Input Form with number of line items based on user input
    By j_gideon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2013, 02:54 PM
  3. Get input from user using application.inputbox. Input should be number and can be 0
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2013, 11:28 AM
  4. Using text box input to lookup number and replace based on user input into new column
    By harl3y412 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2011, 03:15 PM
  5. Replies: 7
    Last Post: 01-19-2011, 05:06 AM
  6. Enter Text Into Cells Based on User Input
    By jdmay in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-23-2010, 11:50 AM
  7. [SOLVED] How do I input a warning message to remind the user to enter into.
    By sugarbrit17 in forum Excel General
    Replies: 3
    Last Post: 01-25-2005, 05:06 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