I want the code to run when workbook loads. I am using Private Sub Workbook_Open(ByVal Sh As Object)
, but it throws an error "Procedure error does not match description of event" - Any ideas please, as Private Sub Workbook_SheetActivate(ByVal Sh As Object)
works.
But I want code to run when workbook opens.
I know that Private Sub Workbook_Open(ByVal Sh As Object)
is not allowed.
See my comment, as previously stated by a few, you can't just change a signature of a standard Excel event handler.
However, you can work within that handler and get access to the worksheets within the workbook.
Private Sub Workbook_Open()
Dim objSheet As Worksheet
For Each objSheet In ThisWorkbook.Sheets
' Do something with the sheet that you're interested in.
Next
End Sub
I hope that helps.
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.