Formula to Add Leading Zeros in Excel

To make a set of numbers of varying length into strings with the same number of characters, try using the TEXT formula.  This formula won’t handle strings, so if you need to add leading zeros to an alphanumeric identifier you might have to try modifying the VBA formula pasted at the end. Here’s an example: … Continue reading “Formula to Add Leading Zeros in Excel”

Excel – Close and Save active workbook in VBA with no Prompt

This VBA code will save an Excel workbook file and close it when it runs.  You could put a button or some other trigger on your worksheets to initiate the macro so that it’s easier for your users to access the macro. Instructions to Install VBA to Save Workbook with No Prompt Step 1: Copy paste this … Continue reading “Excel – Close and Save active workbook in VBA with no Prompt”

[Cheatsheet] VBA String Functions

Function What Does it do? Example Result Len(str) Returns the length of the string Len(“Hello”) 5 Ucase(str) Changes the string to upper case Ucase(“Hello”) HELLO Lcase(str) Changes the string to lower case Lcase(“Hello”) hello Left(str, num) Shorten the string from the left Left(“Hello”,3) Hel Right(str, num) Shorten the string from the right Right(“Hello”,3) llo Mid(str, … Continue reading “[Cheatsheet] VBA String Functions”

Simple Regular Expression Tutorial for Excel VBA

I’ll go through a simple tutorial for using regular expressions for VBA.  This is a great quick start guide for people who have used regular expressions before in other languages.  Just as a review, regular expressions are used to match patterns in strings.  This is a powerful tool that can help you data cleanse and … Continue reading “Simple Regular Expression Tutorial for Excel VBA”

Basic Regular Expression Patterns for Beginners

This is super simplified, but it’s enough to get started with. I remember being confused by the gigantic tables with all the special clauses, so when you’re beginning keep it simple. Remember if you want to match a literal character you can just type it out, unless there’s a special character. Special characters have meanings … Continue reading “Basic Regular Expression Patterns for Beginners”

Get Visual Basic 2010 Express to query an Oracle database

So one of the limitations of Visual Basic 2010 Express is that you can only add data sources to link or query Microsoft databases such as an Access database or MsSQL. So if you need to query an Oracle or mySQL database, for example, it seems that you’re out of luck unless you upgrade to … Continue reading “Get Visual Basic 2010 Express to query an Oracle database”