Site icon port135.com

Solved: “User-defined type not defined” error at declarations of Excel variables (VBA)

You may face “User-defined type not defined” error as you declare Excel specific variables. This issue is little tricky.

Your code may be like this:

Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Dim xlSheet As Excel.Worksheet
You are missing a reference

Solution

This error occurs because of the missing reference. You should add Excel reference before declaring Excel objects. To get rid of this error:

Exit mobile version