+ Reply to Thread
Results 1 to 9 of 9

Need help transferring data from a userform to worksheet depending on a combobox selection

  1. #1
    Registered User
    Join Date
    04-14-2014
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    6

    Need help transferring data from a userform to worksheet depending on a combobox selection

    Hello all. Please go easy on me. I do not use VBA very often however I do manage to put together some code for userforms based on forum topics I find. I use the code below to automatically transfer data from my userform to an excel worksheet. The code works great. Now I would like to update the code so that we do not have to fill out the userform for each PART of the job. For Example: A job can have more than one part, that is why I have the PartNumberBox and PartNumberOfBox. The user can select Part 1 of Part 3 which represents the first part of a 3 part job. With the current code I need to fill out the userform 3 times to get Part 1 of 3, Part 2 of 3 and Part 3 of 3. My question is, can I update this code so that when the user selects an option that has more than one part the code will automatically transfer the data X number of times (where X is the PartNumberOfBox). Hopefully this makes sense. Thanks so much.

    Private Sub CreateJobNumber_Click()
    Dim LastRow As Object
    Dim MyMessage As String

    Set LastRow = Sheets("Datasheet").Range("a65536").End(xlUp)


    LastRow.Offset(1, 1).Value = UniqueCodeBox.Text
    LastRow.Offset(1, 2).Value = RunCodeBox.Text
    LastRow.Offset(1, 3).Value = RunNumberBox.Text
    LastRow.Offset(1, 4).Value = PartNumberBox.Text
    LastRow.Offset(1, 5).Value = PartNumberOfBox.Text
    LastRow.Offset(1, 6).Value = InputCustomerName.Text
    LastRow.Offset(1, 7).Value = InputJobName.Text
    LastRow.Offset(1, 8).Value = InputCustomerJob.Text
    LastRow.Offset(1, 9).Value = InputCustomerPO.Text
    LastRow.Offset(1, 10).Value = InputQuantityOrdered.Text
    LastRow.Offset(1, 11).Value = InputRunDate.Text


    MsgBox "One record written to Sheets(Datasheet)"
    MsgBox "Here is your Unique Code, please take a note for future reference."
    MyMessage = "H" & Me.UniqueCodeBox.Text & "" & Me.RunNumberBox.Value & "" & Me.RunCodeBox.Value & "." & Me.PartNumberBox.Value & "." & Me.PartNumberOfBox.Value
    MsgBox MyMessage
    response = MsgBox("Do you want to enter another NEW JOB record?", _
    vbYesNo)

    If response = vbYes Then

    UniqueCodeBox.Text = ""
    RunCodeBox.Text = ""
    RunNumberBox.Text = ""
    PartNumberBox.Text = ""
    PartNumberOfBox.Text = ""
    InputCustomerName.Text = ""
    InputJobName.Text = ""
    InputCustomerJob.Text = ""
    InputCustomerPO.Text = ""
    InputQuantityOrdered.Text = ""
    InputRunDate.Text = ""





    Else

    Unload UserForm2

    End If

    End Sub

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Need help transferring data from a userform to worksheet depending on a combobox selec

    You can try this modified code.
    Please Login or Register  to view this content.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    04-14-2014
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Need help transferring data from a userform to worksheet depending on a combobox selec

    Pierre, I will definitely try it out and let you know. THanks for your response, totally appreciate the effort!!!

  4. #4
    Registered User
    Join Date
    04-14-2014
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Need help transferring data from a userform to worksheet depending on a combobox selec

    Pierre, that worked beautifully!!! Thank you so much for your help.

  5. #5
    Registered User
    Join Date
    04-14-2014
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Need help transferring data from a userform to worksheet depending on a combobox selec

    Pierre, quick question. Do you see in the code where I have a message box that shows the unique job code that the user just entered. It currently will only show one job code (Part 1 of Part x , where x is the PartNumberOfBox). Is it possible to have the message box show as many job codes as the PartNumberOfBox?
    Thanks
    Anna

  6. #6
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Need help transferring data from a userform to worksheet depending on a combobox selec

    I would need your workbook to answer you. If you don't want to post it here, you might be willing to send it to me in private mail. Let me know.
    Is the job code supposed to be unique? How does it change if you create 3 jobs automatically?

  7. #7
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Need help transferring data from a userform to worksheet depending on a combobox selec

    try the following code:
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-14-2014
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Need help transferring data from a userform to worksheet depending on a combobox selec

    Pierre, I tried it and it works!! Thanks a million you have been such a huge help with this, I just can't thank you enough. Now to work on my next project.... you may have not heard the last of me yet!

  9. #9
    Registered User
    Join Date
    04-14-2014
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Need help transferring data from a userform to worksheet depending on a combobox selec

    Pierre, I would like your opinion on something, would it be okay to email you offline?

+ 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] UserForm Combobox Value based on Worksheet selection (2007)
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-13-2014, 10:52 AM
  2. [SOLVED] Re :Userform Data not Transferring to Worksheet
    By Janto724 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-13-2013, 10:57 AM
  3. Pre fill userform combobox depending on cell selected in worksheet
    By jjyoung in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2013, 10:57 AM
  4. [SOLVED] Fill a cell via textbox on userform depending on combobox selection
    By Rhamilton2512 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-15-2012, 10:29 AM
  5. [SOLVED] Based on userform combobox selection find text on worksheet
    By afpPaul in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2012, 08:07 AM

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