Solved

EXCEL: Using a subroutine in several worksheets

Posted on 2013-01-07
6
248 Views
Last Modified: 2013-01-07
I would like place a subroutine in the workbook section of the workbook and use it in multiple worksheets.

In the General Section of the workbook code I have this:
Private Sub GlobalSub(str As String)
blah blah blah
End Sub

Open in new window


In the Click event of a combo box I have this:
Private Sub combobox1_Click()
ThisWorkbook.GlobalSub ("TEXT")
End Sub

Open in new window


I get a Method or Data Member not found error in line 2 of the click event.
Thoughts?
0
Comment
Question by:gpchicago08
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 48

Expert Comment

by:Martin Liss
ID: 38752120
Change Private to Public
0
 
LVL 48

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 38752126
eg Public Sub GlobalSub(str As String)
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 38752131
It would actually be better to put that sub in a code Module.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Closing Comment

by:gpchicago08
ID: 38752137
duh.
0
 

Author Comment

by:gpchicago08
ID: 38752163
wouldn't that be in the General section of the workbook?
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 38752218
Again the best thing to do is to either cut and paste that sub (after changing to Public) to an existing code module (like Module1), or

Alt+f11 to get to the IDE
From the menu do Insert|Module
Paste or create a new Public sub

Having done that the code is available everywhere in the workbook.

In any case I'm glad I was able to help.

Marty - MVP 2009 to 2012
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question