Member Login

Login
No account yet? Register
 

Search GeoPrac

GeotechSearch.com

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.

GeotechSearch.com Most Popular Search Terms

Home arrow Articles arrow Browse by Category arrow Software and Spreadsheets arrow VBA and Excel for Engineers and Scientists – Part 2
VBA and Excel for Engineers and Scientists – Part 2 - Introduction Print E-mail
Written by Randy Post   
Tuesday, 20 May 2008
Article Index
Introduction
Code Containers
Subroutiness and Functions
Variables and Data Types
Declaring Your Variables
Variable Expressions and Math
Other Functions
Flow Control
Help and Debugging
Custom Spreadsheet Functions
Examples and Downloads
Wrap-up and Recommended Books
Digg!Reddit!
Del.icio.us!Google!
Facebook!Slashdot!
Technorati!StumbleUpon!
Newsvine!Furl!
Yahoo!Ma.gnolia!

String Functions

Why would you want to work with strings (text) in Excel? Aren’t you always just working with numbers? Well Mr. smarty pants, occasionally you might need to label something, or parse a string of comma or tab delimited values, or you might want to use Excel and VBA as a pre- or post-processor from some old program that uses text files for input and output. Or you might want to create a variable chart title or something. Regardless, just take my word for it, you’ll eventually need to work with strings in your applications. Here are the VBA functions you will want to get to know for this kind of work:

  • Split() – Split a string into an array using a delimiter.
  • Left(), Right(), Mid() – Useful for getting the first, last, or middle X number of characters in a string.
  • Format() – Useful for converting numbers into a specific format for display our output.
    • Format(SomeNumber, “0.000”) or
    • Format(SomeDate, “h:mm:ss am:pm”)
  • InStr() and InStrRev() – Find a substring within a string. Useful in conjunction with Left(), Right() and Mid() functions.
  • Len() – Returns the length of the string, also useful with Left(), Right() and Mid() Functions.
  • LCase() and UCase() – Converts case between upper and lower.

Miscellaneous Useful Functions

  • Changing data types – CStr(), CLng(), CSng(), CDbl(), CBool()
  • UBound() and LBound() – Upper bound and lower bound index value of an array (we’ll get to arrays in the third article)
  • Input() – A simple way to get user input
  • MsgBox() – Provide feedback to the user. Can also be used to get a Yes or No answer from the user.


Trackback(0)
Comments (1)add comment

Ted said:

 
Very nice. I have avoided vba and macros up to this point but I think I'll give it a try.
Monday June 16, 2008 10:13AM

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, 21 July 2008 )
 
< Prev   Next >

Site Sponsors

Users Online

No Users Online

Statistics

Members: 126
News: 366
Web Links: 127

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.