Hi guys, anyone know the code how the date picker auto-updated when initialize using excel vba.
Currently, when I run my code the date picker always show the date when I created it.
Thanks in advance.
Hi guys, anyone know the code how the date picker auto-updated when initialize using excel vba.
Currently, when I run my code the date picker always show the date when I created it.
Thanks in advance.
Last edited by weeeee0713; 08-12-2014 at 09:59 PM.
Care to show us the DatePicker Initialize code?
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
?None of us is as good as all of us? - Ray Kroc
?Actually, I *am* a rocket scientist.? - JB (little ones count!)
Here's the code..
Private Sub UserForm1_Initialize() UserForm1.Value = 1 StartDate.Value = Date - 2 EndDate.Value = -1 End Sub Dim a As Integer Private Sub CommandButton1_Click() Dim dStart As Date Dim dEnd As Date Dim pt1 As PivotTable Dim pf1 As PivotField Dim pi1 As PivotItem Sheets("WB Out").Select Application.ScreenUpdating = False On Error Resume Next dStart = StartDate.Value dEnd = EndDate.Value 'Pivot table 1 Set pt1 = ActiveSheet.PivotTables("PivotTable4") Set pf1 = pt1.PivotFields("MFG_Date_Out") pt1.ManualUpdate = True pf1.EnableMultiplePageItems = True For Each pi1 In pf1.PivotItems pi1.Visible = True Next pi1 For Each pi1 In pf1.PivotItems If pi1.Value < dStart Or pi1.Value > dEnd Then pi1.Visible = False End If Next pi1 Application.ScreenUpdating = False pt1.ManualUpdate = False Set pf1 = Nothing Set pt1 = Nothing Sheets("MainMenu").Select End End Sub Private Sub EndDate_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date) End Sub Private Sub StartDate_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date) End Sub
Well, I can see right in your code that it takes the current system date during the initialization.
So, not sure why you'd see anything other than the date two days ago... Date -2StartDate.Value = Date - 2
Post your workbook with this datepicker installed and let's take a look.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks