InputBox returns value from other workbook

FndRdz

New Member
Joined
Aug 30, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hi!

I have developed a Macro in VB and it works correctly when I just have one open Workbook. However, if I have multiple open workbooks, it seems that I got an error in the second code line below:

Set Values_Cell = ActiveWorkbook.Application.InputBox(prompt:="Please select the cell", Type:=8)
Values_Cell.Select

The Error Message that I got is:
Run-time error '1004
Select method of Range class failed.

To be precise, the first code line is used to get the cell address. The following line selects the cell included in Values_Cell.

E.g. if I select the cell E5, Values_Cell contains E5 if I have just one open workbook. When I have two open workbooks, InputBox returns the value in cell E5 of the other workbook. Let's say, if I have the word "number" in cell E5 of the second workbook, Values_Cell will contain "number" instead of E5.

I have tried to run the macro in many ways, but it only works correctly when I just have one open workbook. I have even tried with Set Values_Cell = Application.InputBox(prompt:="Please select the cell", Type:=8) but I have the same result.

Could you help me with some ideas, please? Any suggestion or comment will be really appreciated.

Thank you! Have a good day!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Weird, try thisworkbook instead of activeworkbook
 
Upvote 0
Hi!

Thank you for your suggestion. However, I still have issues with this the InputBox when I have multiple excel documents open. In fact, I have some other Macros and all of them show the same behavior, they reference to another workbook with the InputBox.

Could anyone try these lines on Excel 2016 and see if the problem can be replicated? Could you try running them from different open workbooks, please?

Set Values_Cell = ActiveWorkbook.Application.InputBox(prompt:="Please select the cell", Type:=8)
Values_Cell.Select

Thank you!
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,897
Members
449,097
Latest member
dbomb1414

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