Macro not recognizing Comb Box date

christianbiker

Active Member
Joined
Feb 3, 2006
Messages
379
Hey all...I am using a named range & Combo Box in place of a DatePicker within a userform to ensure users select a proper date. I am using this Combo Box to hide all rows in a spreadsheet that do not match the date selected in a Combo Box however it does not seem to be recognizing the selected date when the macro is run and instead it hides all rows within the spreadsheet. The date in the required column is formatted to a date and the Combo Box is formatted to a date as well but it isn't working. This was not an issue when I was originally using the DatePicker but I would prefer to avoid that route.

Why isn't my Combo Box working?

Thanks!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
VBA Code:
Private Sub courtdate_Change()

    With courtdate
        .Value = Format(.Value, "m/d/yyyy")
    End With

End Sub

Private Sub filtercourt_Click()

    With courtdate
        .Value = Format(.Value, "m/d/yyyy")
    End With

Application.ScreenUpdating = False

    Dim ws As Worksheet
    Dim rng As Range
    Dim cell As Range

' Set the worksheet
    Set ws = ThisWorkbook.Sheets("MAIN")

' Set the range to the data range in Column H (adjust as needed)
    Set rng = ws.Range("R6:R50")

' Loop through each cell in the specified range
    For Each cell In rng
        ' Check if the cell value is "Yes"
        If cell.Value <> courtdate Then
            ' Toggle the row visibility
            cell.EntireRow.Hidden = Not cell.EntireRow.Hidden
        End If
    Next cell

Application.ScreenUpdating = True

MsgBox "Your court docket has been generated." & vbNewLine & vbNewLine & "Click ""Ok"" to continue."


End Sub
 
Upvote 0
Try using:

Code:
If cell.Value <> cdate(courtdate) Then
 
Upvote 0
Solution

Forum statistics

Threads
1,223,788
Messages
6,174,570
Members
452,573
Latest member
Cpiet

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