VBA Calendar

Aron19

New Member
Joined
Sep 14, 2011
Messages
20
Can someone please give me some newbie advice on how to make a VBA calendar entry date to show up as centered rather than right jusitified?

Here is the sheet code

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

If Target.Column = 4 Then

ActiveCell.Clear
End If



If Target.Column = 4 Then

UserForm1.Show
End If


End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub


Here is the module code


Sub opencalendar()
UserForm1.Show
End Sub


Here is the User Form code

Private Sub UserForm_Initialize()
If IsDate(ActiveCell.Value) Then
calender1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Date
End If

End Sub
Private Sub Calendar1_Click()


ActiveCell.Value = Calendar1.Value
Unload Me

End Sub

Private Sub cmdClose_Click()
Unload Me
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
I did it like this and am getting an error from the sheet

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

If Target.Column = 4 Then

ActiveCell.Clear
End If



If Target.Column = 4 Then

UserForm1.Show
End If

ActiveCell.Value = Calendar1.Value
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
 
Upvote 0
It doesn't go there. It goes in the Calendar's click event procedure:

Code:
Private Sub Calendar1_Click()
    ActiveCell.Value = Calendar1.Value
    ActiveCell.HorizontalAlignment = xlCenter
    Unload Me
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,390
Members
452,909
Latest member
VickiS

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