oursgris
oursgris

Reputation: 2882

DatePicker in Excel Vba

I need to add a datepicker in Excel in a custom vba form.

I know that I can use MSCOMCT2.ocx but it seems to be obsolete with Excel 2010 : user will have to install a custom package.

I need that the code will work from Excel 2003 to 2010 without installation (or at least without throwing an error message if the component isn't available). I can't control the running environnement.

IS there any solution ? like a custom datepicker in full vba ?

Upvotes: 2

Views: 9452

Answers (2)

Ryan Nguyen
Ryan Nguyen

Reputation: 25

Instead of date picker, i am using auto populate in all the date column in my excel. Please see below.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xRg As Range, xCell As Range
On Error Resume Next
If (Target.Count = 1) Then
    If (Not Application.Intersect(Target, Me.Range("H4,H7")) Is Nothing) Then _
        Target.Offset(0, x1down) = Date
    Application.EnableEvents = False
    Set xRg = Application.Intersect(Target.Dependents, Me.Range("H4,H7"))
    If (Not xRg Is Nothing) Then
        For Each xCell In xRg
            xCell.Offset(0, x1down) = Date
                        Next
    End If
    Application.EnableEvents = True
End If
End Sub

Upvotes: 0

Michael
Michael

Reputation: 507

I've used the following successfully on a roll-out to a mix of Excel 2003 and 2007. The authors do say it should be compatible with all versions.

https://sites.google.com/site/e90e50/calendar-control-class

Upvotes: 3

Related Questions