user11952026
user11952026

Reputation:

Variable not defined error in image control variable in vba

enter image description here

hIcon = Sheet1.Image1.Picture.Handle

I have sheet1 with image control with the name image1 but still getting this issue? Please help me with this. where I am doing wrong?

Upvotes: 1

Views: 559

Answers (1)

Vityata
Vityata

Reputation: 43595

Compile Error: Variable not defined

means that the variable hIcon is not defined. Write Dim hIcon as Variant on the line above the error, to define it.

As it is compiling error, every time before running the code, make sure to go to the VBEditor menu and press Debug>Compile VBA Project to see whether other errors like this exist:

enter image description here

Upvotes: 1

Related Questions