Thursday, October 10, 2013

Code Example - VBA: Do Something With Your Strings

VBA is not the best language when it comes to String manipulation; it's not nearly as robust as, say, Python's Slicing ability. But that doesn't mean you can't do useful things with VBA. In fact, here are a few slightly more advanced techniques to get you started...

Saturday, July 20, 2013

Code Example: Different Ways to Work With Arrays

This post is inspired by this StackOverflow question asking about passing a 2D array around... Let's say you have two Subs or Functions (or one of each) between which you want to pass an array (any array) of values. Here is an example of Subs trying to do something like this, but unfortunately failing:
Sub StartSub()
Dim myValues() As Integer
' Fill the array
StopSub myValues
End Sub

Sub StopSub(otherValues As Integer)
MsgBox otherValues(2)
End Sub
The right solution to this problem is not always obvious, but there are a number of options at your disposal. Let's have a look...

Saturday, May 25, 2013

Code Example: Creating Menu Buttons for VBA Add-Ins

Sure, you can write VBA code. Sure, you can add a button to spreadsheet to trigger that code. Sure, you can set that code to run automatically in the background after a certain action is performed. But, how do you set up an add-in so that nobody has to open and see a blank spreadsheet every time they want to choose to just run your code (perhaps on a different workbook than where your code resides)? Well, here's a good way to get started...

Thursday, May 16, 2013

Code Example: Oracle SQL Query for Yesterday's Data

Do you have any queries running against "yesterday's" (i.e. the previous business day's) data where you actually have to adjust every week to account for the weekend? Here's a simple trick to make this less painful on Monday morning...

Tuesday, April 16, 2013

Playing With Python

I'm pretty good at VBA, I'd say. (NO, that doesn't mean I can just record macros! but that's a different story.) As much as I like VBA for what I can do with it, people - other programmers in particular - seem to think VBA is the red-headed step-child or black sheep of languages. Perhaps I should look into something else?

Tuesday, April 2, 2013

Golfing Tip - VBA: Split a string into a character array

Golfing code is the practice or activity of reducing usable, functional code to the smallest number of characters or bytes that you can, while still maintaining the code's original functionality. I participate in golfing (and other) challenges at CodeGolf.SE (part of the StackExchange network), so from time to time, I will set aside some effort to elaborate on certain solutions I provide.

Today's tip can also be found by following this link.
When you're done reading, see what else you can do with Strings!

Saturday, March 30, 2013

CodeGolf Answer Explained: Removing Vowels

I participate in challenges at CodeGolf.SE (part of the StackExchange network), so from time to time, I will set aside some effort to elaborate on certain solutions I provide.

Today's solution (which can be found by following this link) is in response to a question titled: "Remove vowels without using too many different characters"

comments powered by Disqus