Search code examples
exceluserformmultipagevba

Is it possible to change the number in an object name by using a loop?


I have multiple pages in a userform multipage and each page has an image object. The image of page1 is named image1, the image of page2 is named image2, and so on.

I need to reference these image objects inside a loop. Is it possible to do something like "image"&i where i is the number in the image name? I tried it but I get a syntax error.


Solution

  • You can use this:

    UserForm1.Controls ("Image" & i).Picture = LoadPicture(imageName)