Code doesn't work when 2 workbooks opened

harveya915

Board Regular
Joined
Sep 4, 2015
Messages
141
I have a workbook called Call Info 2.0
On this workbook in Sheet1 I have an image. When I click on the image it brings up a UserForm1
It works all fine and dandy, except for, if I have another workbook opened and when I try to click on the image I get an error:
Run-time error '381': Could not set the List property. Invalid Property array index.
When I hit the debug button, it takes me to the Sheet1 code of the Call Info 2.0:
VBA Code:
Sub Image1_Click()
UserForm1.Show vbModeless
End Sub

If I close the second workbook and try clicking the image again, it works! Any help would be appreciated.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Post your initialization event code
I'm a bit of a noob. All I have learned is from researching. Would you mind explaining a bit more? I can only assume, by what I have kinda learned so far, is that it would look something like this...

Private Sub Workbook_Initialize()
Workbooks("Call Info 2.0.xlsx").Activate
End Sub

And then this would go in the "This Workbook" code?
Am i along the right path?
 
Upvote 0
What I mean is that I need you to show me the code that generates the error. Do you need the other workbook to be active? In general I'd always recommend declaring references to workbooks/worksheets/ranges for example set WB1= workbooks("Workbook name"). Thisworkbook will always refer to the workbook that the code is found in.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,246
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top