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,
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
Last edited by a moderator: