0
votes

I am trying to configure a button to run multiple macros, but I keep getting the sub or function not defined error seen below.

This is my directory structure

The Subs exist in sheets 2 through 5 and the macro is in Module 1. Here is what I have tried:

  1. Adding "Public" in front of Sub across the sheets
  2. Adding "Button2_click" to the "READ_ME" sheet
  3. Adding "Call" in front of the Sub names
  4. Double checking the sub names match

I don't usually use VBA, any suggestions for what I am doing incorrectly?

1
Which one of the sheets' routines are you trying to call?Rory
Why not put the sub in a general code module? As a general rule of thumb, event handlers belong in sheet modules but general-purpose subs/functions belong in regular modules.John Coleman

1 Answers

1
votes

If your subs exist in other sheets, You have to call them with specifying the sheet name along with subname.

For ex -

Sub Button2_Click()
    Sheet2.GenerateIdentityData
End Sub

Or you can move your subs to general modules as well to overcome this problem.