+ Reply to Thread
Results 1 to 3 of 3

userform merge vaule of combobox and sheet cell value

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    10-17-2007
    Location
    Tasmania, Australia
    MS-Off Ver
    2019, 365(v2403)
    Posts
    368

    userform merge vaule of combobox and sheet cell value

    Hi,
    I have a userform that has a few txtboxs, combobox etc.

    TextBox12 displays a value of a helper cell on sheet 2 cell J2
    ComboBox7 drops down to display users names

    Is there a way I can convert the full name(eg:Joe Bloggs) selected in ComboBox7 to Initials(eg: JB)
    and merge it with the value in TextBox12, for example the result will be JB01

    Private Sub CheckBox1_Click()
        TextBox14.Value = " " & Time
    End Sub
    
    Private Sub CommandButton2_Click()
        UserForm1.Show
    End Sub
     
    Private Sub CommandButton1_Click()
    ScreenUpdate = False
     Sheets("Enquiries Record").Activate
     Range("A65536").Select
     Selection.End(xlUp).Select
     ActiveCell.Offset(1).Select
     ActiveCell.Value = Me.TextBox1
     ActiveCell.Offset(0, 2).Value = Me.TextBox12
     ActiveCell.Offset(0, 3).Value = Me.ComboBox2
     ActiveCell.Offset(0, 4).Value = Me.ComboBox1
     ActiveCell.Offset(0, 5).Value = Me.TextBox2
     ActiveCell.Offset(0, 6).Value = Me.TextBox14
     ActiveCell.Offset(0, 7).Value = Me.TextBox3
     ActiveCell.Offset(0, 8).Value = Me.ComboBox3
     ActiveCell.Offset(0, 9).Value = Me.ComboBox4
     ActiveCell.Offset(0, 10).Value = Me.ComboBox5
     ActiveCell.Offset(0, 11).Value = Me.ComboBox7
     ActiveCell.Offset(0, 13).Value = Me.TextBox11
     ActiveCell.Offset(0, 14).Value = Me.TextBox5
     ActiveCell.Offset(0, 15).Value = Me.TextBox6
     ActiveCell.Offset(0, 16).Value = Me.TextBox7
     ActiveCell.Offset(0, 17).Value = Me.TextBox8
     ActiveCell.Offset(0, 18).Value = Me.TextBox9
     ActiveCell.Offset(0, 19).Value = Me.ComboBox6
     ActiveCell.Offset(0, 20).Value = Me.TextBox10
     ActiveCell.Offset(0, 21).Value = Me.TextBox13
    
     ComboBox2 = ""
     ComboBox1 = ""
     TextBox3 = ""
     ComboBox3 = ""
     ComboBox4 = ""
     ComboBox5 = ""
     ComboBox7 = ""
     TextBox11 = ""
     TextBox5 = ""
     TextBox6 = ""
     TextBox7 = ""
     TextBox8 = ""
     TextBox9 = ""
     ComboBox6 = ""
     TextBox10 = ""
     TextBox13 = ""
       
     Sheets("New Enquiry").Activate
     ActiveWorkbook.Save
      Unload Enquirysubmit
      ScreenUpdate = True
     End Sub
    
    Private Sub UserForm_Initialize()
    TextBox1.Value = " " & Date
    TextBox2.Value = " " & Time
    TextBox12.Value = Sheet2.Range("J2").Value
    End Sub

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: userform merge vaule of combobox and sheet cell value

    Hello russhris,

    This should work...
    Private Sub CommandButton1_Click()
    
        Dim Initials   As String
        Dim Word       As Variant
        Dim Words      As Variant
    
            Words = Split(ComboBox7, " ")
                For Each Word In Words
                    Initials = Initials & Chr(Asc(Word))
                Next Word
    
            ScreenUpdate = False
    
            Sheets("Enquiries Record").Activate
            Range("A65536").Select
            Selection.End(xlUp).Select
    
     	ActiveCell.Offset(1).Select
     	ActiveCell.Value = Me.TextBox1
     	ActiveCell.Offset(0, 2).Value = Initials & Me.TextBox12
     	ActiveCell.Offset(0, 3).Value = Me.ComboBox2
     	ActiveCell.Offset(0, 4).Value = Me.ComboBox1
     	ActiveCell.Offset(0, 5).Value = Me.TextBox2
     	ActiveCell.Offset(0, 6).Value = Me.TextBox14
     	ActiveCell.Offset(0, 7).Value = Me.TextBox3
     	ActiveCell.Offset(0, 8).Value = Me.ComboBox3
     	ActiveCell.Offset(0, 9).Value = Me.ComboBox4
     	ActiveCell.Offset(0, 10).Value = Me.ComboBox5
     	ActiveCell.Offset(0, 11).Value = Me.ComboBox7
     	ActiveCell.Offset(0, 13).Value = Me.TextBox11
     	ActiveCell.Offset(0, 14).Value = Me.TextBox5
     	ActiveCell.Offset(0, 15).Value = Me.TextBox6
     	ActiveCell.Offset(0, 16).Value = Me.TextBox7
     	ActiveCell.Offset(0, 17).Value = Me.TextBox8
     	ActiveCell.Offset(0, 18).Value = Me.TextBox9
     	ActiveCell.Offset(0, 19).Value = Me.ComboBox6
     	ActiveCell.Offset(0, 20).Value = Me.TextBox10
     	ActiveCell.Offset(0, 21).Value = Me.TextBox13
    
     	ComboBox2 = ""
     	ComboBox1 = ""
     	TextBox3 = ""
     	ComboBox3 = ""
     	ComboBox4 = ""
     	ComboBox5 = ""
     	ComboBox7 = ""
     	TextBox11 = ""
     	TextBox5 = ""
     	TextBox6 = ""
     	TextBox7 = ""
     	TextBox8 = ""
     	TextBox9 = ""
     	ComboBox6 = ""
     	TextBox10 = ""
     	TextBox13 = ""
       
     	Sheets("New Enquiry").Activate
     	ActiveWorkbook.Save
    
      	Unload Enquirysubmit
    
      	ScreenUpdate = True
    
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Valued Forum Contributor
    Join Date
    10-17-2007
    Location
    Tasmania, Australia
    MS-Off Ver
    2019, 365(v2403)
    Posts
    368

    Re: userform merge vaule of combobox and sheet cell value

    Hi Leith,

    Thank you very much. Works like a charm when you submit it to the spreadsheet.

    Is there a way to have that update the record number txtbox on the userform before submitting? As in, it will say record "5" using the helper cell on sheet 2 and when you select a name from the list(combobox7) and click on the selection the record number will change to "AH05"

    Also, I know this is probably out of scope for this thread. But I set the formatting of the helper column to prefix the record number with a zero"0" but it doesn't display that zero on the user form.

+ 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. ComboBox in USERFORM used to change which sheet output goes
    By InvalidTxtString in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-06-2016, 06:31 PM
  2. Replies: 0
    Last Post: 08-18-2015, 04:13 PM
  3. [SOLVED] How to use a list from Excel Sheet with Userform ComboBox
    By JRidge in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-26-2014, 09:04 AM
  4. [SOLVED] concatenate combobox from form to a merge cell
    By aimjhun in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2014, 03:17 AM
  5. [SOLVED] userform combobox to look up list in sheet
    By H_Kennedy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-21-2013, 02:30 AM
  6. Copy and Paste from one sheet to another sheet - userform - combobox
    By ahhbunny in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-07-2013, 09:49 PM
  7. Macro to move rows from one sheet to another sheet based on a cell vaule
    By d55272 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 10-09-2012, 03:33 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