Member Login

Login
No account yet? Register
 

Search GeoPrac

Site Sponsors

Even More News and Blog Posts!

New on GeoPrac.net, the Other News and Blogs page has had a major facelift. To supplement our regular GeoNews and Articles, we aggregate news feeds and blog entries from all over the web into one easy to browse source. Check it out!  

Become an Author

GeoPrac.net is a community site, we are only as good as the content our members contribute!

Whether it's a one time contribution, or a monthly or quarterly article, please consider becoming an author

Subscribe by Email

Subscribe to GeoPrac.net Headlines by Email. Powered by FeedBurner.com, Don't forget to follow instructions to verify your subscription!

Enter your email address:

RSS Feeds

To subscribe to GeoPrac.net headlines, use one of the buttons below. Or view other available feeds or read more about RSS.

Home arrow Articles arrow Browse by Category arrow Software and Spreadsheets arrow VBA and Excel for Engineers and Scientists
VBA and Excel for Engineers and Scientists - VBA Introduction Print E-mail
Written by Randy Post   
Thursday, 05 April 2007
Article Index
VBA Introduction
Getting Started
Your First VBA Code!
Digg!Reddit!
Del.icio.us!Google!
Facebook!Slashdot!
Technorati!StumbleUpon!
Newsvine!Furl!
Yahoo!Ma.gnolia!

Your First VBA Code!

Ok, you’ve stuck with me for this far, the least I can do for you is show you how to implement the classic piece of code that every programmer starts with, “Hello World!”. 

In the VBE, go to the “Insert” menu, and choose to insert a “Module”. You will see a code window popup, and if you look in the Project Explorer, you will see that there is a new code module called “Module1”. Type Listing 1 into your code window.

Sub HelloWorld()
  MsgBox "Hello World!"
End Sub

Now, you can run it a couple different ways. The first way would be to simply put your cursor somewhere in the code, and press the play button on the menu bar of the VBE. Another way would be to switch back to the main Excel window, and go to click the play button on the Visual Basic toolbar, or from the Tools>Macro menu. Then select to run the “Hello World” subroutine. You should get a window that lists the name of your “Hello World” subroutine and click the “Run” button.

Closure and Next Article

In the next article, we will start to get into more of the VBA language. We will cover various types of containers for your code, variables, data types, functions, etc.

technorati tags:
vba !


Trackback(0)
Comments (0)add comment

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley

security image
Write the displayed characters


busy
Last Updated ( Monday, 28 January 2008 )
 
< Prev

Site Sponsors

Users Online

No Users Online

Statistics

Members: 48
News: 308
Web Links: 36

GeoPrac.net © 2007 Randy Post unless noted.
Terms of Use | Copyright Info | Privacy Policy | Disclaimer | Sitemap

Other Randy Post Sites: RnRPost.com | NameDrawing.net 

Article Copyright

All content in the ARTICLES section of GeoPrac.net is copyrighted by their authors unless otherwise noted and reproduced here with permission. Refer to the copyright page or the terms of use for more information.