Combo box within userform to populate combo selection within sheet

pure vito

Board Regular
Joined
Oct 7, 2021
Messages
183
Office Version
  1. 365
Platform
  1. Windows
Hi There this is my first time posting but not my first time here i have found an incredible amount of information here that has helped me along,
i only discovered VBA a few weeks ago and decided to try to create my own workbook to help me along in trying to learn how to get the most out of VBA,

I have hit many snags and spent hours searching for solutions, so now iv'e decided to turn to the experts amongst you, it always feels like a burden asking anyone for help so i thank you in advance,
and again i am very new to this so please be patient with me :)

so to the actual issue i will post a picture hopefully making it a little more clear to what i want to achieve,
I need the combo box within the user form to populate column E in the sheet with the selection form the user form as you can see column E already has a selection box i'm not to sure what it is called,
but when i fill in the row with all the other boxes i need it to chose an option pre selected in the user form combo box i really hope this makes sense ,

i have posted below the code i am using to populate the sheet so i imagine it would need to be apart of this,



VBA Code:
Private Sub presstobookco_Click()

    Dim t As Long
    Dim S As String
    Dim X As Variant 'array
   
   
    Sheets("CO").Activate
    ActiveSheet.Range("B1").Activate

    Do While IsEmpty(ActiveCell.Offset(t, 0)) = False
        t = t + 1
    Loop

    ActiveCell.Offset(t, 0).Activate 'The Empty Cell

    S = bookingpartsco.Value
    X = Split(S, Chr(10)) 'your bookingparts.value split into an array. if chr(10) doesn't work, try chr(13) or vbNewLine or vbCrLf
    i = 0 'just a counter
   
    For Each v In X
        ActiveCell.Offset(i, 0).Value = CleanTrim(v)
        i = i + 1
    Next v
 
  Sheets("CO").Activate
    ActiveSheet.Range("F1").Activate

    Do While IsEmpty(ActiveCell.Offset(t, 0)) = False
        t = t + 1
    Loop

    ActiveCell.Offset(t, 0).Activate 'The Empty Cell

    q = bookingqtyco.Value
    X = Split(q, Chr(10)) 'your bookingparts.value split into an array. if chr(10) doesn't work, try chr(13) or vbNewLine or vbCrLf
    i = 0 'just a counter
   
    For Each v In X
        ActiveCell.Offset(i, 0).Value = CleanTrim(v)
        i = i + 1
    Next v
 
  Sheets("CO").Activate
    ActiveSheet.Range("G1").Activate

    Do While IsEmpty(ActiveCell.Offset(t, 0)) = False
        t = t + 1
    Loop

    ActiveCell.Offset(t, 0).Activate 'The Empty Cell

    f = bookingqtyadvco.Value
    X = Split(f, Chr(10)) 'your bookingparts.value split into an array. if chr(10) doesn't work, try chr(13) or vbNewLine or vbCrLf
    i = 0 'just a counter
   
    For Each v In X
        ActiveCell.Offset(i, 0).Value = CleanTrim(v)
        i = i + 1
    Next v
  
   Sheets("CO").Activate
    ActiveSheet.Range("D1").Activate

    Do While IsEmpty(ActiveCell.Offset(t, 0)) = False
        t = t + 1
    Loop

    ActiveCell.Offset(t, 0).Activate 'The Empty Cell

    j = bookinginico.Value
    X = Split(j, Chr(10)) 'your bookingparts.value split into an array. if chr(10) doesn't work, try chr(13) or vbNewLine or vbCrLf
    i = 0 'just a counter
   
    For Each v In X
        ActiveCell.Offset(i, 0).Value = CleanTrim(v)
        i = i + 1
    Next v
 
    Sheets("CO").Activate
    ActiveSheet.Range("H1").Activate

    Do While IsEmpty(ActiveCell.Offset(t, 0)) = False
        t = t + 1
    Loop

    ActiveCell.Offset(t, 0).Activate 'The Empty Cell

    j = bookinginico.Value
    X = Split(j, Chr(10)) 'your bookingparts.value split into an array. if chr(10) doesn't work, try chr(13) or vbNewLine or vbCrLf
    i = 0 'just a counter
   
    For Each v In X
        ActiveCell.Offset(i, 0).Value = CleanTrim(v)
        i = i + 1
    Next v
 
 
 'msg box
 Dim UserResponse As Integer

UserResponse = MsgBox("You Did It Brah!", vbYesNo, "Parts Added to DataBase")

If UserResponse = vbYes Then

'Your command for a yes answer goes here

Else

'Your command for a no answer goes here

End If
 


End Sub


 



Function CleanTrim(ByVal S As String, Optional ConvertNonBreakingSpace As Boolean = True) As String
  Dim X As Long, CodesToClean As Variant
  CodesToClean = Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, _
                       21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 127, 129, 141, 143, 144, 157)
  If ConvertNonBreakingSpace Then S = Replace(S, Chr(160), " ")
  For X = LBound(CodesToClean) To UBound(CodesToClean)
    If InStr(S, Chr(CodesToClean(X))) Then S = Replace(S, Chr(CodesToClean(X)), "")
  Next
  CleanTrim = Trim(S)
End Function

thumbnail_IMG_5334 (1)sgwsg.jpg
 
Last edited by a moderator:

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I already feel like this doesn't make sense ? within the sheet i have formula that counts if the value in Column F is "IN" or "OUT" i need the user form to be able to transfer all the information given to a row and select an option "IN" or "OUT" in column E based on the selection within the user form.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top