Hi Scott,
Thanks for the rep points. It's my pleasure to help, especially for someone who is trying to learn to fish.
I was able to find out the cause of some of your problems, but not the reason why the problem occurs.
...showed a problem wherein only the first textbox value associated with the comboboxes posts to the spreadsheet. That problem persists.
1. For some unknown reason the ComboBox .ListIndex value always had the value -1, even when ComboBoxes had lists in them. When I changed the test from .ListIndex to looking for the value in the ComboBox I had success. Your test for the first ComboBox always tested for the VALUE.
2. The use of 'Option Explicit' at the top of each code module is highly recommended. To prevent typos from ruining days and weeks of work 'Option Explicit' is NEEDED at the top of each code module. This prevents errors caused by missspellings and FORCES every variable to be DECLARED (e.g. dim i as Integer).
http://www.cpearson.com/excel/DeclaringVariables.aspx
Important excerpts of the code I used from Sub xxx follow:
Dim RowCount As Long
Dim response As Long
If Len(Trim(CbAllocate1.Value)) = 0 Then
Exit Sub ' nothing selected
End If
Set tbl = Sheets("Data").ListObjects(1)
Set col = tbl.ListColumns(CbAllocate1.Value)
Set findheader = col.Range
Sheets("Data").Cells(Rows.Count, findheader.Column).End(xlUp).Offset(1).Value = TbSplit1.Value
If Len(Trim(CbAllocate2.Value)) > 0 Then
Set tbl = Sheets("Data").ListObjects(1)
Set col = tbl.ListColumns(CbAllocate2.Value)
Set findheader = col.Range
Sheets("Data").Cells(Rows.Count, findheader.Column).End(xlUp).Offset(0).Value = TbSplit2.Value
End If
If Len(Trim(CbAllocate3.Value)) > 0 Then
Set tbl = Sheets("Data").ListObjects(1)
Set col = tbl.ListColumns(CbAllocate3.Value)
Set findheader = col.Range
Sheets("Data").Cells(Rows.Count, findheader.Column).End(xlUp).Offset(0).Value = TbSplit3.Value
End If
If Len(Trim(CbAllocate4.Value)) > 0 Then
Set tbl = Sheets("Data").ListObjects(1)
Set col = tbl.ListColumns(CbAllocate4.Value)
Set findheader = col.Range
Sheets("Data").Cells(Rows.Count, findheader.Column).End(xlUp).Offset(0).Value = TbSplit4.Value
End If
If Len(Trim(CbAllocate5.Value)) > 0 Then
Set tbl = Sheets("Data").ListObjects(1)
Set col = tbl.ListColumns(CbAllocate5.Value)
Set findheader = col.Range
Sheets("Data").Cells(Rows.Count, findheader.Column).End(xlUp).Offset(0).Value = TbSplit5.Value
End If
If Len(Trim(CbAllocate6.Value)) > 0 Then
Set tbl = Sheets("Data").ListObjects(1)
Set col = tbl.ListColumns(CbAllocate6.Value)
Set findheader = col.Range
Sheets("Data").Cells(Rows.Count, findheader.Column).End(xlUp).Offset(0).Value = TbSplit6.Value
End If
I will address the questions you raise inside your sample file in the following post.
Lewis
Bookmarks