cdate convert problem to filter datas

elevisse

New Member
Joined
Jul 30, 2012
Messages
28
Hi All,
I would like to filter datas with textbox date but some computers use different date format. My file doesnt filter with yyyy/mm/dd or mm/dd/yyyy format. For example, I use dd/mm/yyyy format, it works in my computer. Whats the problem? what should I do, it works every formats and Should L4 cell be dd/mm/yyyy format. Please see codes below. Could you please help me. Thanks.

Code:
Private Sub CommandButton1_Click()
    
    Application.ScreenUpdating = False
  
    Application.EnableEvents = False
    Dim Son, Devir
       
       
    Range("A3:O" & Rows.Count).AutoFilter Field:=5
    Son = Cells(Rows.Count, 2).End(3).Row
    
    TextBox1.Value = Format(TextBox1.Value, "dd/mm/yyyy")
    
    If TextBox1 <> "" Then
        
        If IsDate(TextBox1) Then
            Devir = WorksheetFunction.SumIf(Range("E5:E" & Son), "<" & CLng(CDate(TextBox1)), Range("H5:H" & Son))
            Range("H4") = Range("H4") + Devir
            
            Range("A3:O" & Rows.Count).AutoFilter Field:=5, Criteria1:="<" & CLng(CDate(TextBox1))
            
            If Cells(Rows.Count, 2).End(3).Row > 3 Then
                Range("A5:O" & Rows.Count).EntireRow.Delete
                Range("A3:O" & Rows.Count).AutoFilter Field:=5
                Cells(Rows.Count, 8).End(3).Offset(2, 0) = WorksheetFunction.Sum(Range("H4:H" & Cells(Rows.Count, 2).End(3).Row))
            End If
            
            Range("A3:O" & Rows.Count).AutoFilter Field:=5
           
           Unload tarih
            
       [L4] = CDate(TextBox1.Value) - 1
       
       Application.CutCopyMode = False
       Application.Run "formulerun"
       
Selection.AutoFilter
                
        Else
            MsgBox "Please enter starting date!", vbCritical
        End If
    Else
        MsgBox "Please enter starting date!", vbCritical
    End If
 
 
   Application.EnableEvents = True
 
 Range("H:H,J:J").Select
    Range("J1").Activate
    Selection.NumberFormat = "#,##0.00"
    Range("A1").Select
 
    Application.ScreenUpdating = True
        
End Sub



Private Sub TextBox1_Change()

End Sub

Private Sub UserForm_initialize()
  TextBox1.Value = Format(Date, "dd/mm/yyyy")
    
End Sub

Sub selectdate ()
startingdate.Show
End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
You could use Application.International to determine the regional date setting. Then adjust your code to suit.

Code:
[color=darkblue]Sub[/color] Date_Order()
    [color=darkblue]Select[/color] [color=darkblue]Case[/color] Application.International(xlDateOrder)
        [color=darkblue]Case[/color] 0: MsgBox "System date order is month-day-year"
        [color=darkblue]Case[/color] 1: MsgBox "System date order is day-month-year"
        [color=darkblue]Case[/color] 2: MsgBox "System date order is year-month-day"
    [color=darkblue]End[/color] [color=darkblue]Select[/color]
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,727
Messages
6,126,508
Members
449,316
Latest member
sravya

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