I am trying to format a date into a fixed format everytime someone changes cell B8, entering data manually seems to trigger Macro-checkdateformat but when copy pasting into cell doesnt trigger.
Below is my code.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$8" Then
Call Checkdateformat
End If
End Sub
Target can be more than a single cell. You just need to check if B8 is one of them. To see if a cell is in a larger group of cells (or just one other cell), use Intersect.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If not intersect(target, range("B8")) is nothing then
'B8 is part of Target
on error goto safe_exit
application.enableevents = false
Call Checkdateformat
End If
safe_exit:
application.enableevents = true
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.