We barely touched on Else statements in our discussion on the Excel =IF() workbook function because the last parameter is the workbook equivalent of ELSE. In VBA we are not required to always have an ELSE section of code, but what if you do want to do something when a condition fails (is FALSE).
It turns out it is super easy and only requires you to type the word "Else" inside of your current IF statement.
If (condition) Then
' Code to execute if condition is true
Else
' Code to execute if condition is false
End If
Thanks for watching,
Lucius LaFromboise
www.engsuite.org
Taking Excel to The Next Level Playlist: • Excel =IF Function - Taking Excel to the N...
Getting Started with Excel VBA: • Getting Started with Excel VBA