More Listbox Help Please

twinpowr

Board Regular
Joined
Mar 14, 2007
Messages
73
Hi i have been building this listbox with some fantastic help from this board. I use the following code to capture a date a place this in column h of the selected listbox item.

Code:
Private Sub EnterDate_Click()
Dim lastrow As Long
With Worksheets("data")
    .Range("H" & ListBox1.ListIndex + 2).Value = TextBox1.Value
    .Range("l" & ListBox1.ListIndex + 2).Value = ""
    
End With
Call filterwithdates
Call copytocompleted
Call clearfiltercontents
Call deleteemptyrows
'
 Call UserForm_Initialize
End Sub

This works fine as long as i have the full range displayed in the listbox. I am using this code to filter the data based on a value in a combobox which is:-

Code:
Private Sub CommandButton3_Click()
Dim Rng As Range
Dim Dn As Range
Dim Ac As Integer
With ListBox1
.Clear
.ColumnCount = 9
.ColumnWidths = "80,80,80,85,85,85,85,85,85"
End With
With Worksheets("Data")
Set Rng = .Range(.Range("fullrange"), .Range("A" & Rows.Count).End(xlUp))
End With

    For Each Dn In Rng
      If Trim(Dn.Offset(, 1)) = ComboBox1.Value Then
            With ListBox1
                .AddItem Trim(Dn)
                     For Ac = 1 To 8
                        .List(.ListCount - 1, Ac) = Dn.Offset(, Ac)
                    Next Ac
           End With
     End If
Next Dn
End Sub

When i enter the date, after the data has been filtered it does not match from the selected item, but some other row in the dataset.

I can post the full code if needed. If anyone can help or point me in the right direction. I would be most obliged.

Thank you in advance.

Ally.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,224,606
Messages
6,179,865
Members
452,948
Latest member
UsmanAli786

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