Change date format in cell when using excel date addin

nando88

Board Regular
Joined
Jun 22, 2013
Messages
124
I found this excel addin, and I need to change the date format and locale, but when I use numberformat in the cell, the date format doesn't change:
Excel date addin

This si the code I am using:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Selection.NumberFormat = "[$-es-HN]dddd, dd"" de ""mmmm"" de ""yyyy;@\]"
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then
Call CallDatePickerWithVBA
End If
End Sub
Sub CallDatePickerWithVBA()
    Dim TestWkbk As Workbook
    Dim obj As Object

    If Val(Application.Version) >= 12 Then
        Set TestWkbk = Nothing
        On Error Resume Next
        Set TestWkbk = Workbooks("WinDatePicker.xlam")
        On Error GoTo 0
        If TestWkbk Is Nothing Then
            MsgBox "Sorry the Date Picker add-in is not open."
        Else
            Application.Run "'" & TestWkbk.Name & "'!OpenDatePicker", obj
        End If
    End If
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try this code to Worksheet_Change event :

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = "$A$1" Then
Selection.NumberFormat = "dd \d\e mmmm \d\e yyyy;@\]"
End If

End Sub
 
Upvote 0
Still no luck. I think I figured out how to make it work, but you can't change the format on the same cell with vba. I tried this several times and noticed that the format does change but the addin switches back to the original format selected in the app, so the only way I figured out how to make this work is by addin the date in another cell and selecting the right format in the desired cell.
If you or anyone else finds a simpler way to do this through VBA, I will appreciate it.
Thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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