[mso] Excel - Macro (reply from Chip Pearson)

Hi folks...

I'm taking a little break from the list to get some work done, so I have
email turned off. Just wanted to let you know this so you realize I
won't see any replies right now. 

But someone recently asked about some VBA stuff that was obtained from
Excel MVP Chip Pearson's web site. I dropped Chip a note for you and he
was kind enough to supply the following information. Hope this answers
any questions you had. Good luck with it! Cheers...catch you guys a
little later...

- - - - - - - - 

Hi Dian,

If you could forward this to him, post it on list, or whatever, much
appreciated.....

With the exception of special flavors of VBA (Visual Basic for
Applications) procedures called "Event Procedures" and a few other
things, all VBA code should
reside in a Standard Code module in a workbook.   

Open the VBA Editor by going to your "Tools" menu, choosing the "Macros"
item, then the "Visual Basic Editor" item, or just press ALT+F11.  This
will open the VBA Editor.  There, go to the "View" menu and choose
"Project Explorer" (or just press CTRL+R).  Note, the Project Explorer
may already be visible.  It typically appears on the left side of the
screen, and is a "tree view" window, that allows you to expand or close
variable "folders" -- it looks and feels much like Windows Explorer.  

Find your project in the list, it will say "VBAProject (filename.xls)"
where filename.xls is the name of the file.  Select this, and then go to
the "Insert" menu and choose "Module" (not "Class Module").  This will
open a code window in the main area of the VBA Editor, and name the
module "Module1".  You can cut and paste the code directly from my web
page in this module. Be careful of things like line-wrapping.  What
should appear on one line of code may get split to two lines during the
paste.  Welcome to HTML.

Once you've put the code in the module, go back to the main Excel
screen. There, go to the "Tools" menu, choose "Macros" and then "Macros"
(or just press
ALT+F8).  This displays the macros dialog.  On that dialog, select the 
ALT+macro from the list, and click run.

VBA code is always stored within Workbooks (in Excel -- in Word it is
Documents, and the same sort of thing applies to the other Office
applications).  You can't have VBA "outside" of a Workbook.  Well, you
can store the text of a macro in any sort of file, but Excel can execute
code only when it exists within a workbook.

I hope this helps.

Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com 



Dian Chapman
Technical Consultant, Instructor,
Microsoft MVP & TechTrax Editor

Word AutoForm/VBA eBook: http://www.mousetrax.com/books.html
Tutorial web site: http://www.mousetrax.com/techpage.html
TechTrax Ezine: http://www.mousetrax.com/techtrax/

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx?Subject=unsubscribe

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
http://www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: