Active Workbook

Aurum

New Member
Joined
Mar 31, 2010
Messages
9
I use a workbook that processes real time stock prices with a VBA timer and sends out an alert when a price goes into a desired range. But this requires this workbook to be always the active workbook, and when I opened another workbook the alert failed. I tried adding something like ThisWorkbook.Sheet1 to all the Ranges in the code, but it didn't work.

Could anyone please tell me how i can make reference to the specific workbook that runs in the background, so that another opened workbook won't cause confusion? Thanks.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi

What nature is the alert? ie is it an email, a popup or what> Also, please could you pot your code so we can see what it is doing.
 
Upvote 0
Thanks for your replies. Actually I have solved this problem on my own but at that time I could not post a reply here - seems there were some problems with the database here.

I need to read a range of prices with for loop - in the form of Range("Price").Offset(i,0) , where Price, a cell I name, is the column header of prices. I tried ThisWorkbook.Sheet1.Range("Price").Offset(i,0) but it didn't recognise the range Price, instead I tried ThisWorkbook.Sheets("Realtime prices").Range("Price").Offset(i,0)and it works. Turns out that it recognises only the sheet name but not the code.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

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