Question

I've tried using the code that many sites have suggested to autorun a list of macros upon opening an Excel workbook. Attached is my VBA code on ThisWorkbook:

Private Sub WorkbookOpen()


MsgBox "STOP!  Do NOT attempt to highlight any fields manually!" & vbCrLf & _
     "Any highlighting will be overwritten upon reentry of this workbook.", vbOKOnly     +vbExclamation

Call Melanoma.ReformatDeplete
Call Melanoma.CScheckNO
Call Melanoma.CScheckMissing
Call Glioma.ReformatDeplete
Call Glioma.ReformatGBM
Call Glioma.CScheckNO
Call Glioma.CScheckMissing
Call Breast.ReformatDeplete
Call Breast.CScheckNO
Call Breast.CScheckMissing
Call Lymphoma.ReformatDeplete
Call Lymphoma.CScheckNO
Call Lymphoma.CScheckMissing
Call Lung.ReformatDeplete
Call Lung.CScheckNO
Call Lung.CScheckMissing
Call Miscellaneous.ReformatDeplete
Call Miscellaneous.CScheckNO
Call Miscellaneous.CScheckMissing
Call Normals.ReformatDeplete
Call Normals.CScheckNO
Call Normals.CScheckMissing


End Sub

Obviously, I saved the workbook as a 2010 macro-enabled workbook, but when I open the workbook, nothing happens on its on, I still have to click the "run button" in VBA

Any suggestions?

Thanks!

Was it helpful?

Solution

You are close, just add the underscore

Private Sub Workbook_Open()

OTHER TIPS

There are two main ways to run the macro on workbook open

  1. Which Portland Runner has already mentioned in his post. Private Sub Workbook_Open()

  2. Use Sub Auto_Open() in a module. While we are at it, you may also want to check THIS. The link is about Configure a macro to run automatically upon opening a workbook

Private Sub Workbook_Open() is better than Sub Auto_Open() because of many reasons as mentioned in that link.

There are two possible reasons the macro will not run automatically:

  1. security settings
  2. the macro is not located in the workbook code area
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top