else without if error popup

Else Without If Error in VBA: Why Is it Happening?

What you’re seeing is a compile error that indicates that an Else (or ElseIf) keyword was not preceded by a correct If statement. Meaning, the compiler found an Else statement (which it will highlight for the user) without seeing an If statement in the lines

How to Fix Compile Error: Sub or Function Not Defined

What’s worse than getting a runtime error in Excel VBA? A compile error. That’s because the actual error is not always highlighted, rather the opening Sub or Function statement. “Sub or Function not Defined” indicates a compile error. VBA displays this message when it cannot

Vbcrlf: The Visual Basic Carriage Return Line Feed

To facilitate the reading of a messages by users or readers – especially long messages – it is necessary to format it conveniently through new lines, alignment, new paragraphs, etc. For a specialized word processing software like MS Word, this is easy. For example, to

Subscript Out of Range: How Do You Fix It?

When running a VBA procedure, you might receive this error message “Run-time error ‘9’, Subscript out of range”. In this article, we will talk about the possible reasons for the occurrence of this error and the ways to fix it.  According to our recent review,

Ubound example

The VBA Ubound function

Description The VBA UBound (Upper Bound) function returns the upper limit of an array as opposed to the LBound (Lower Bound) that returns the lower limit of an array. Both functions (UBound and LBound) can be combined to determine the size of an array. Syntax

How to use the OnKey method in Excel VBA

As a VBA developer you sometimes need to use a key or a combination of keys to run a procedure without using the command button on a UserForm. This is possible with the VBA onkey method. Syntax The syntax for the OnKey method is: Application.OnKey