Trying to set cursor using VBA

hatzonick

New Member
Joined
Jul 17, 2014
Messages
3
Newby here. Please be gentle! When I run my excel macro and keep the cursor in the workbook that the macro is running in, the macro is able to set the cursor position to where I need it. I use:

Workbooks("TwsDdeNick_prod.xlsm").Worksheets("BasicOrders").Range("A10").Activate

Now, when I run this macro and then move the cursor to another workbook before the macro is finished I get the following message when the macro is attempting to move the cursor in the workbook where the macro was run:

Run-time error ‘1004’:
Activate method of Range class failed

How can I be able to move my cursor freely between workbooks but have the macro operate independently of what workbook I’m currently in? Thanks so much in advance.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi and welcome to the forum.

It can be tricky to go to a cell in another Workbook using Activate; it is better to us Goto. Try;

Code:
Application.Goto (Workbooks("TwsDdeNick_prod.xlsm").Worksheets("BasicOrders").Range("A10"))

The workbook "TwsDdeNick_prod.xlsm" must be open for this to work.
 
Upvote 0
Hi and welcome to the forum.

It can be tricky to go to a cell in another Workbook using Activate; it is better to us Goto. Try;

Code:
Application.Goto (Workbooks("TwsDdeNick_prod.xlsm").Worksheets("BasicOrders").Range("A10"))

The workbook "TwsDdeNick_prod.xlsm" must be open for this to work.

It is open along with other workbooks in the same instance of excel.
 
Upvote 0

Forum statistics

Threads
1,216,568
Messages
6,131,462
Members
449,652
Latest member
ylsteve

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