Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,533
- Office Version
- 365
- 2016
- Platform
- Windows
I hope someone is able to help me.
I have a worksheet that has a Private Worksheet_Activate function associated with it. My understanding is that this code will be triggered each time the worksheet is "activated"?
When I manually step through my tabs, when I select this particular worksheet, the code is executed and performs the desired results. (reset3 basically defaults a series of cells and hides some rows and returns the user back to this worksheet)
When I run the application's code (not manually stepping through worksheets), the worksheet does not update when activated through VB code. I thought it might have something to do with EnableEvents, but I assume not since after the code is run, I get the results with manual worksheet selection. (although when I step through the code line by line, I still get no results and ?EnableEvents in the immediate window comes up blank ... assume false)
Any advice for a resolution?
Jenn
I have a worksheet that has a Private Worksheet_Activate function associated with it. My understanding is that this code will be triggered each time the worksheet is "activated"?
Code:
Private Sub Worksheet_Activate()
Call reset3
ActiveSheet.Protect
End Sub
Code:
Sub reset3()
'
' A routine to default and hide all user entry fields prior to involuntary entering of a record data entry
' Called by worksheet_activate (Edit) event & positive pivvottable
'
With Application
.ScreenUpdating = False
.EnableEvents = False 'disable worksheet change
.DisplayAlerts = False
End With
Sheets("Enter_Miss").Activate
ActiveSheet.Unprotect
' COMMON1
Range("$J$8").Value = "0"
Range("$D$10").Value = ""
Range("$J$10").Value = ""
Range("$J$11").Value = ""
Range("$T$11").Value = ""
Range("$AA$11").Value = ""
Range("$L$8:$M$8").ClearContents
Range("$P$8:$AA$8").ClearContents
' DIAMONDS
Range("$e$15").Value = ""
Range("$J$15").Value = ""
Range("$P$15").Value = "NA"
Range("$X$15").Value = "NA"
Range("$E$16").Value = "Yes"
Range("$J$16").Value = "NA"
Range("$P$16").Value = "NA"
Range("$X$16").Value = "NA"
Range("$E$17").Value = "NA"
Range("$J$17").Value = "NA"
Range("$X$17").Value = "NA"
' FIELDS
Range("$F$21").Value = ""
Range("$F$22").Value = ""
' COURTS
Range("$F$26").Value = ""
' COMMON2
Range("$G$30").Value = ""
Range("$G$31").Value = ""
' HIDE ACTIVITY ROWS
ActiveSheet.Unprotect
Rows("7:37").Select
Selection.EntireRow.Hidden = True
Range("$E$5:$F$5").Locked = False
Range("$E$5") = "0"
Application.EnableEvents = True
ActiveSheet.Protect
End Sub
When I manually step through my tabs, when I select this particular worksheet, the code is executed and performs the desired results. (reset3 basically defaults a series of cells and hides some rows and returns the user back to this worksheet)
When I run the application's code (not manually stepping through worksheets), the worksheet does not update when activated through VB code. I thought it might have something to do with EnableEvents, but I assume not since after the code is run, I get the results with manual worksheet selection. (although when I step through the code line by line, I still get no results and ?EnableEvents in the immediate window comes up blank ... assume false)
Any advice for a resolution?
Jenn