I am using Excel 2003. I have a combobox on my userform called cbDescription. I am using a dynamic range called data. I have had it working fine but had to play with the code to get it to insert a new row in the spreadsheet when I added a new item. After totally messing it up I am just trying to populate my fields on the userform, which I haven't finised yet. But my question is why would the drop down not scroll in a combo box.
the code that populates the combobox would come from the following:
Private Sub UserForm_Initialize()
frmItemListing.cbDescription.SetFocus
ClearForm
Me.MultiPage1.Value = 0 ' go to page 1
CurrentYear
TabFocus
Dim Found As Long, i As Long
Dim cel As Range
'Set Range Name to suit
MyList = "Data"
Set DataList = Range(MyList)
ReDim FArray(DataList.Cells.Count)
i = -1
For Each cel In DataList
On Error Resume Next
Found = Application.WorksheetFunction.Match(CStr(cel), FArray, 0)
If Found > 0 Then GoTo Exists
i = i + 1
FArray(i) = cel
Exists:
Found = 0
Next
ReDim Preserve FArray(i)
Call BubbleSort(FArray)
cbDescription.ListRows = i + 1
cbDescription.List() = FArray
End Sub
Sub BubbleSort(MyArray As Variant)
Dim First As Integer
Dim Last As Integer
Dim i As Integer
Dim j As Integer
Dim Temp As String
Dim List As String
First = LBound(MyArray)
Last = UBound(MyArray)
For i = First To Last - 1
For j = i + 1 To Last
If MyArray(i) > MyArray(j) Then
Temp = MyArray(j)
MyArray(j) = MyArray(i)
MyArray(i) = Temp
End If
Next j
Next i
End Sub
Also, I am not new to Excel but I am new to Excel Programming.
Due date fast approaching on this project. Will answer any questions you have in order to get this done.
cward
the code that populates the combobox would come from the following:
Private Sub UserForm_Initialize()
frmItemListing.cbDescription.SetFocus
ClearForm
Me.MultiPage1.Value = 0 ' go to page 1
CurrentYear
TabFocus
Dim Found As Long, i As Long
Dim cel As Range
'Set Range Name to suit
MyList = "Data"
Set DataList = Range(MyList)
ReDim FArray(DataList.Cells.Count)
i = -1
For Each cel In DataList
On Error Resume Next
Found = Application.WorksheetFunction.Match(CStr(cel), FArray, 0)
If Found > 0 Then GoTo Exists
i = i + 1
FArray(i) = cel
Exists:
Found = 0
Next
ReDim Preserve FArray(i)
Call BubbleSort(FArray)
cbDescription.ListRows = i + 1
cbDescription.List() = FArray
End Sub
Sub BubbleSort(MyArray As Variant)
Dim First As Integer
Dim Last As Integer
Dim i As Integer
Dim j As Integer
Dim Temp As String
Dim List As String
First = LBound(MyArray)
Last = UBound(MyArray)
For i = First To Last - 1
For j = i + 1 To Last
If MyArray(i) > MyArray(j) Then
Temp = MyArray(j)
MyArray(j) = MyArray(i)
MyArray(i) = Temp
End If
Next j
Next i
End Sub
Also, I am not new to Excel but I am new to Excel Programming.
Due date fast approaching on this project. Will answer any questions you have in order to get this done.
cward