+ Reply to Thread
Results 1 to 4 of 4

Update date when initialize

Hybrid View

  1. #1
    Registered User
    Join Date
    08-03-2014
    Location
    Philippines
    MS-Off Ver
    Microsoft Office 2010
    Posts
    43

    Update date when initialize

    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.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Update date when initialize

    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!)

  3. #3
    Registered User
    Join Date
    08-03-2014
    Location
    Philippines
    MS-Off Ver
    Microsoft Office 2010
    Posts
    43

    Re: Update date when initialize

    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

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Update date when initialize

    Well, I can see right in your code that it takes the current system date during the initialization.
    StartDate.Value = Date - 2
    So, not sure why you'd see anything other than the date two days ago... Date -2

    Post your workbook with this datepicker installed and let's take a look.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. multipage initialize help
    By kmakjop in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-12-2014, 10:47 AM
  2. How to update Text Box with date 14 days after selected date...
    By mjc61 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-25-2014, 08:10 PM
  3. VBA to update pivot tables date between value - Date error
    By delboy2405 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-11-2013, 01:46 PM
  4. initialize combobox
    By joe_for_good in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 09-23-2010, 08:54 AM
  5. initialize an array to 0
    By kdp145 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2006, 04:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1