Excel VBA

This category will hold articles regarding developement in Excel VBA. It will serve as a wiki and an Excel VBA Framework for myself.

Some development tasks reoccur for every customer. Since I am a lazy bum it will be nice to have a central source where I can reuse source code from.

Recently a collegue had to import a SharePoint list into Excel for automated processing.

Below you can find the source code that I provided him with as an example.

Source Code

Sub LinkedSharePointList()
    ActiveSheet.ListObjects.Add SourceType:=xlSrcExternal, _
        Source:=Array(<"URL String">, <"ListNameString">, _
        <"{GUIDString}">), LinkSource:=True, Destination:=Range("A1")
End Sub

With this collection of articles I want to build a wiki for myself as well as others.

The goal is to build not only a little framework for Excel VBA, but also a collection of general tips and hints on issues I experienced working with Excel and Visual Basic for Excel.

Once completed, I am guessing it never will be, this will serve me well. Like my wife always says, I am "Mr. Forgetful" and a "Lazy Bum".

Yes dear, I love you too.

And it's true, good programmers are lazy!


The following function checks, if a worksheet is existing under a given name in a provided workbook object.

Source Code

' @Author - Alexander Bolte
' @Description - Checking, if a worksheet is existing in given workbook under given name.
' @Param wrk - an object of type Workbook.
' @Param name - a String holding the name of the worksheet existance should be checked for.
' @Returns - true, if worksheet exists under given name, else false.
Public Function worksheetExists(ByRef wrk As Workbook, ByVal name As String) As Boolean
Dim ret As Boolean
Dim tmp As Worksheet

On Error GoTo errHandle:

Set tmp = wrk.Worksheets(name)
ret = Not (tmp Is Nothing)

If Err.Number <> 0 Then
ret = False
End If

Set tmp = Nothing
worksheetExists = ret
End Function