2017-09-13 91 views
1

日期顯示在列A單元格中,單擊該行中列A到C中的單元格。有沒有代碼?這裏是我的代碼已經顯示該行的任意位置點擊單擊日期Excel 2010的VBA代碼

Private Sub Worksheet_SelectionChange(ByVal Target As Range) 
    Cells(Target.Row, 1) = Date 
End Sub 

回答

0

嘗試,因爲當日期,

Private Sub Worksheet_SelectionChange(ByVal Target As Range) 
    if not intersect(target, range("A:C")) is nothing then 
     dim trg as range 
     for each trg in intersect(target, range("A:C")) 
      cells(trg.row, "A") = date 
     next trg 
    end if 
End Sub