I am wondering if it is possible to call a private Sub worksheet_Change(ByVal Target As Range) type of sub from another public sub? I know that you can't really 'call' the sub but Run it, however my attempts at running the sub doesn't seem to work. This is what I have tried:
Sub AccessTransfer()
Range("A1:F1").Select
Selection.Copy
Sheets("Sheet2").Select
ActiveSheet.Paste
ActiveCell.Offset(0, 6).Value = "Oven"
Range("A65536").End(xlUp).Offset(1, 0).Select
Run.Application "Private Sub Worksheet_Change(ByVal Target As Range)"
Sheets("Sheet1").Select
Application.CutCopyMode = False
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Application.CountIf(Range("A:A"), Target) > 1 Then
MsgBox "Duplicate Entry", vbCritical, "Remove Data"
Target.Value = ""
End If
Range("A65536").End(xlUp).Offset(1, 0).Select
End Sub
Any help or suggestions on how to fix my problem would be most appreciated.
Worksheet_Change
into a module and then call that from both. – tjb1sheet1.cells(1, 1) = sheet1.cells(1, 1).value
– user4039065.Select
/.Activate
. @Jeeped - isn't the default.Value
? Why either leave it out of the left side, or add it to the right? For confirmation for the user? – BruceWayneTarget.Value = ""
) in the Worksheet_Change which will trigger another event. For a couple more, you haven't isolated Target to column A and have not dealt with more than a single cell being Target. – user4039065