In my macro I have a userform to filter data. sometimes after I use the macro and then run it later the previously entered data will show back up in the userform. what can i put in my code to clear the data after it filters???
Private Sub btnFilter_Click()
Dim startDate As String
Dim shift As String
'reads date from the userform
startDate = tbstartdate.Value 'tbStartDate is the name of the textbox for Starting Date
shift = tbshift 'tbshift is the name of the textbox for shift
Application.DisplayAlerts = False
.AutoFilterMode = False
.Range("a1:p1").AutoFilter Field:=2, Criteria1:=shift
.Range("a1:p1").AutoFilter Field:=1, Criteria1:=(">=" & startDate), _
Operator:=xlAnd, Criteria2:=("<=" & startDate)
Range("A1:P" & Cells(Rows.Count, "A").End(xlUp).Row).Copy
If I used tbstartdate="" where do I put it and do I also need to have one for the tbshift??
There should be "End Sub" you can type it right before that... but i think the real problem might be the Hide comment... If I am mistaken please somebody correct me but Hiding doesnt unloads the form and consumes memory... so I would prefer to use "Unload me" instead of "Userform1.Hide"
Or Unload with the name of the form. When I use Unload Me, I've had some unpredictable results from time to time. Perhaps I just wasn't using it right, when I first started playing with userforms, but I've gotten out of the habit of using Me. Just my $0.02