System date format and excel calendar input.

ditto

New Member
Joined
Mar 21, 2009
Messages
20
In my workbook there are some cells for date entry. I have put excel popup calendars in these cells. But I want the calendar to put the date in the English(UK) format ie. dd/mm/yyyy. But this workbook goes to many places and I want the calendar to put the date in the said format even if the system date format is defined otherwise. Is there a way to change the system date fomat on opening a workbook? Or should I modify the code for the calendar given below?
Code:
Option Explicit
Private Const CalendarInputControlName = "CalendarInputControl"
Private Const CalendarInputFrame1Name = "CalendarInputFrame1"
Private Const CalendarInputFrame2Name = "CalendarInputFrame2"
Public Sub HideCalendarInputControl()
    On Error Resume Next
    ActiveSheet.OLEObjects(CalendarInputControlName).Delete
    ActiveSheet.Shapes(CalendarInputFrame1Name).Delete
    ActiveSheet.Shapes(CalendarInputFrame2Name).Delete
End Sub
Public Sub ShowCalendarInputControl( _
       ByVal Cell As Range _
       )
    Dim Calendar As Object
    Dim CalendarFrame As Shape
    Dim CellFrame As Shape
    Dim HorizontalDelta As Double
    Dim VerticalDelta As Double
    HideCalendarInputControl
    If Cell.Left + Cell.Width + 5 + 182.5 > ActiveWindow.VisibleRange.Columns(ActiveWindow.VisibleRange.Columns.Count).Left Then
        HorizontalDelta = -Cell.Width - 10 - 182.5
    End If
    If Cell.Top + Cell.Height + 5 + 123 > ActiveWindow.VisibleRange.Rows(ActiveWindow.VisibleRange.Rows.Count).Top Then
        VerticalDelta = -Cell.Height - 10 - 123
    End If
    Set CellFrame = ActiveSheet.Shapes.AddShape(msoShapeRectangle, Cell.Left, Cell.Top, Cell.Width + 1, Cell.Height + 1)
    CellFrame.Name = CalendarInputFrame1Name
    With CellFrame.OLEFormat.Object.ShapeRange
        .Fill.Visible = msoFalse
        .Line.ForeColor.SchemeColor = 12
        .Line.Weight = 2.5
    End With
    Set CalendarFrame = ActiveSheet.Shapes.AddShape(msoShapeRectangle, Cell.Left + Cell.Width + 5 + HorizontalDelta, Cell.Top + Cell.Height + 5 + VerticalDelta, 182.5, 123)
    CalendarFrame.Name = CalendarInputFrame2Name
    With CalendarFrame.OLEFormat.Object.ShapeRange
        .Fill.Visible = msoFalse
        .Line.ForeColor.SchemeColor = 12
        .Line.Weight = 2.5
    End With
    On Error Resume Next
    Set Calendar = ActiveSheet.OLEObjects.Add(ClassType:="MSCAL.Calendar.7", Left:=Cell.Left + Cell.Width + 7 + HorizontalDelta, Top:=Cell.Top + Cell.Height + 7 + VerticalDelta, Width:=180, Height:=120)
    If Err.Number <> 0 Then
        MsgBox "The Microsoft Calendar Control is not installed on this computer."
        HideCalendarInputControl
        Exit Sub
    End If
    Calendar.Name = CalendarInputControlName
    Calendar.LinkedCell = Cell.Address
    Calendar.Visible = False
    Calendar.Visible = True
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,215,063
Messages
6,122,927
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top