VBA - Visual Basic for Applications

Sometimes it is necessary to get a folder path from the user instead of receiving a file path.

The Excel Application class is providing a corresponding function, which is used in below method.

Source Code

If you have to delete a worksheet from a workbook, you can use below source code.

Source Code

1
2
3
4
5
6
7
8
9
10
' @Author - Alexander Bolte
' @ChangeDate - 2014-10-08
' @Description - Deleting a worksheet named like sheetName from given target Workbook, if a worksheet under given sheetName exists.
' @Param trg - an initialized workbook object.
' @Param sheetName - a String holding a unique worksheet name.
Public Function deleteWorksheet(ByRef trg As Workbook, ByVal sheetName As String)
    If worksheetExists(trg, sheetName) Then
        Call trg.Worksheets(sheetName).Delete
    End If
End Function

Referenced Functions

The following functions are referenced.

 Check if a worksheet exists

 

If you have to delete all records from a table using Access VBA DAO, the following method might be helpful.

Subcategories

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.

This category holds articles regarding general things in MS Office VBA independent from the MS Office application.  

This category holds articles regarding Access VBA, but also general things I come accross Access and its usage in companies.