Skip to content

Instantly share code, notes, and snippets.

@ecounysis
Created May 9, 2011 02:14
Show Gist options
  • Save ecounysis/961929 to your computer and use it in GitHub Desktop.
Save ecounysis/961929 to your computer and use it in GitHub Desktop.
Unit Tests for VBA
Sub Test(Assertion As Boolean, Description As String)
ActiveCell.Value = Description
If Assertion Then
With Selection.Interior
.ColorIndex = 10
.Pattern = xlSolid
End With
Else
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
End If
With Selection.Font
.Name = "Lucida Sans Unicode"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 2
End With
ActiveCell.Offset(1, 0).Range("A1").Select
End Sub
Sub RunTests()
Dim ws As Worksheet
Set ws = Worksheets(1)
If ws.Name <> "tests" Then
Worksheets.Add
Set ws = Worksheets(1)
ws.Name = "tests"
End If
ws.Range("A1:Z65000").Select
With Selection
.ClearContents
.Interior.ColorIndex = xlNone
End With
ws.Range("A1").Select
Tests
ws.Range("A1").Select
ActiveCell.Columns("A:A").EntireColumn.ColumnWidth = 120
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment