Vincent88
Active Member
- Joined
- Mar 5, 2021
- Messages
- 382
- Office Version
- 2019
- Platform
- Windows
- Mobile
I use below code to show the cell value as sheetname in column C (example : C2) when the cells in both column A and B in the same row is nonblank but it does not trigger to change when both cells (for example : A2 and B2) are filled until I click Cell C and enter.
How to modify the code to have the cell C to show the sheetname automatically once both cells A and B are filled with data.
CODE
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 3 Or Application.CountA(Cells(Target.Row, 1).Resize(, 2)) < 2 Then Exit Sub
Application.EnableEvents = False
Target.Value = ActiveSheet.name
Target.NumberFormat = "d mmm yyyy"
Target.HorizontalAlignment = xlRight
Application.EnableEvents = True
End Sub
How to modify the code to have the cell C to show the sheetname automatically once both cells A and B are filled with data.
CODE
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 3 Or Application.CountA(Cells(Target.Row, 1).Resize(, 2)) < 2 Then Exit Sub
Application.EnableEvents = False
Target.Value = ActiveSheet.name
Target.NumberFormat = "d mmm yyyy"
Target.HorizontalAlignment = xlRight
Application.EnableEvents = True
End Sub