简体   繁体   中英

Single Click VBA code for date Excel 2010

The date shows in column A cell with a single click on cell in column A through C in that row. Is there a code for that? Here is the code I have already that shows the date when clicking anywhere in the row

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

Try it as,

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM