Archive for the ‘VBA Basics’ Category.

Graphics I Grok

As a big-time college basketball junkie (Villanova ‘96 grad school–Kerry Kittles et al), I thought the NY Times had two excellent NCAA basketball tourney graphics. No pie charts! I needed a tech assist from Dick to learn how to do this, so I’m not as timely as I should have been, and that [...]

Using a Class Property to do more than just Assign or Query a Value

The purpose of this article is to introduce various capabilities of a class property. It is not meant to serve as an introduction to classes and objects. See the references section for introductory pages.
The typical use of a Class Property is to assign a value or to query its value as in the [...]

Testing Strings Using Left

The "wrong" way:

Sub FindTotals()
   
    Dim rCell As Range
   
    For Each rCell In Sheet1.Columns(1).Cells
        If Left$(rCell, 5) = "Total" Then
            'Do something
        End If
    Next rCell
   
End Sub

The "right" way:

Sub FindTotals2()
   
    Dim rCell As [...]

Random Sorts

Red wants to have a kind-of lottery for his students. He will award them prizes based on a random drawing, but wants to weight each student based on the number of assignments turned in. Normally, I would accomplish this by typing the name of each student in column A one time for every [...]

Website update

This post introduces several new items on the www.tushar-mehta.com website.

Automating pastevalues

There are a lot of good comments on the mouse shortcut entry to Paste Values. I am curious though, because I haven't seen one variation of a macro to Paste Values that I thought was more straightforward.
The commented method involves two steps, one, to copy the range, and two, to perform the Paste Special, [...]

AutoFill Macro

I've recently added a new macro to my Personal.xls (that's four now!). This one is to replace the cumbersome Edit > Fill > Series > Autofill (alt-e-i-s, alt-f, enter).

Sub FillSeriesAutoFill()
    If TypeName(Selection) = "Range" Then
        Selection.DataSeries , xlAutoFill
    End If
End Sub

This uses the DataSeries method of the Range object. [...]

Create Post Slugs

This function seems to do the same thing that WordPress does when it converts the post's title into a url. That is, it makes all valid characters lowercase, removes invalid characters, and converts spaces into dashes (or whatever you call Chr$(45)).
It's all part of an ill-advised attempt at using Excel to make WordPress posts.
The [...]