在特定单元上运行Excel VBA Datepicker

我在这里使用Datepicker解决scheme在VBA的文本框中格式化MM / DD / YYYYdate

我可以从一个Sub运行它,但是可以通过点击特定的单元格来运行它吗?

您可以在Worksheet_BeforeDoubleClick上使用Worksheet_BeforeDoubleClick事件,并在特定单元格(或多个单元格)被双击时触发代码。

 Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Address = "$C$2" Then UserForm1.Show `change to desired cell address and the name of your userform End Sub 

这个代码应该放在Worksheet模块中

这里是事件的文档https://msdn.microsoft.com/en-us/library/office/dn301178.aspx