Userform Code

G

Guest

Here is my code:

Private Sub cmbxPeriod_Change()
Sheets("CEU Database").Unprotect Password:="dataworf"
Sheets("Code").Range("P2").Value = usfReset.cmbxPeriod.Value
Application.ScreenUpdating = False
Sheets("CEU Database").Select
Cells.Select
Selection.AutoFilter Field:=7, Criteria1:=Sheets("Code").Range("P2").Value
Application.ScreenUpdating = True
Sheets("CEU Database").Protect Password:="dataworf",
DrawingObjects:=False, Contents:=True, Scenarios:=True
End Sub

I have used a variation of this code many times in the past without problem.
However, the usfReset.cmbxPeriod.Value is a date. One issue might be that
the cells are already filtered by one criteria.
 
T

Tom Ogilvy

Private Sub cmbxPeriod_Change()
Sheets("CEU Database").Unprotect Password:="dataworf"
Sheets("Code").Range("P2").Value = clng(usfReset.cmbxPeriod.Value)
Sheets("Code").Range("P2").Numberformat = _
Sheets("CEU Database").Range("G2").Numberformat
Application.ScreenUpdating = False
Sheets("CEU Database").Select
Cells.Select
Selection.AutoFilter Field:=7,
Criteria1:=Sheets("Code").Range("P2").Text
Application.ScreenUpdating = True
Sheets("CEU Database").Protect Password:="dataworf",
DrawingObjects:=False, Contents:=True, Scenarios:=True
End Sub

Untested, but might work.
 
B

Bob Phillips

Didn't Dave Peterson solve this for you in your previous post? If not,
explain why it didn't work.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top