I have my VBA code and a ActiveX command button which runs the code in one workbook. I need the code to run against data in different workbooks which will have different names.
The code works fine against data in a different workbook if I run it from the VBA application window.
The code can also run when I start it using a command button if I copy the data onto the same worksheet where the command button is
The problem seems to be that the code doesn't start the first time I click on the command button. All that first click does it make the worksheet where the command button is the current worksheet. When I then click the second time, the code runs, but it fails because if is looking for the data on the worksheet where the button is and not in the workbook where the data is.
I tried changing the button property "Take Focus on Click" to False, but it makes no difference.
I've used command buttons before without problem but am at a new company and perhaps there is a different setting on this version of Excel or at this company. We use Microsoft 365 here.
Thanks for any help.
The code works fine against data in a different workbook if I run it from the VBA application window.
The code can also run when I start it using a command button if I copy the data onto the same worksheet where the command button is
The problem seems to be that the code doesn't start the first time I click on the command button. All that first click does it make the worksheet where the command button is the current worksheet. When I then click the second time, the code runs, but it fails because if is looking for the data on the worksheet where the button is and not in the workbook where the data is.
I tried changing the button property "Take Focus on Click" to False, but it makes no difference.
I've used command buttons before without problem but am at a new company and perhaps there is a different setting on this version of Excel or at this company. We use Microsoft 365 here.
Thanks for any help.