Your modified version ran successfully on my computer; I didn't get the "Byref argument mismatch" error.
As far as I can see, all you've done in Find_Matching_Images() is change the variable name of the first parameter from sWebSiteURL to x, and the one line that references it, IE.navigate x.
Within Find_Matching_Images(), 'x' is still a local variable (because it's declared in the parameter list), not the global 'x' you've defined, so your modified Find_Matching_Images() is effectively the same as mine. Your global 'x' is only global within Define_Variables() and Test(), and Test() is passing the global value of 'x' to the local variable 'x' in Find_Matching_Images(). Do you see how using the same variable name for a global and local variable is confusing?!
If you want to use your global 'x' string within Find_Matching_Images(), you would change the sub parameter definition to:
Private Sub Find_Matching_Images(sImageSearchString As String, destinationStartCell As Range)
BUT, global variables are generally bad programming and should only be used when absolutely necessary. In this case I can't see the point of using a global.
Instead, you could put the web site URL in a cell, for example A1 in Sheet1, and call Find_Matching_Images() like this:
The search word could also be picked up from a cell. I gave a clue to this method in the last sentence of my first post.
If you are calling Find_Matching_Images() in a loop with many different web sites and/or image search strings and performance is an issue, one change I would make to my original code is to move the declaration/definition of the IE object outside Find_Matching_Images() and pass it as a parameter instead, like this:
With this the IE object is created and destroyed only once, resulting in a faster run time.
Bookmarks