回覆列表
  • 1 # 值得一看的職場那些事

    需要用VBA,以Excel2007為例,方法如下;

    3、回到工作表,用滑鼠左鍵拖動出來一個日曆控制元件,調整大小和位置,如下圖:

    4、滑鼠左鍵在“日曆控制元件”上雙擊,調出VBA編輯器,把下面這段程式碼複製貼上到裡面

    Private Sub Calendar1_Click()

    ActiveCell = Format(Calendar1.Value, "yyyy-mm-dd")

    Me.Calendar1.Visible = False

    End Sub

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Target.Column = 1 Then

    If Target.Row > 1 Then

    With Me.Calendar1

    .Visible = True

    .Top = Target.Top + Target.Height

    .Left = Target.Left + Target.Width

    .Value = Date

    End With

    Else

    Me.Calendar1.Visible = False

    End If

    Else

    Me.Calendar1.Visible = False

    End If

    End Sub

    其中“ If Target.Column = 1 Then

  • 中秋節和大豐收的關聯?
  • 白皮蒜種屬於軟蒜苗還是硬蒜苗?