I need help limiting my macro to only a specific workbook

weiser386

New Member
Joined
Sep 2, 2015
Messages
10
I have created an excel spreadsheet that updates with production data every 3 seconds and part of the macro changes the format of the file to be full screen because it is displayed on a giant TV monitor in our production office...my issue is that once this file is opened on a computer if you have another excel file open it makes them full screen and attempts to update every 3 seconds. How do i make this macro only run on my desired workbook?


here is my code:

This code is located in "thisworkbook"

Private Sub Workbook_Open()

Call MyMacro

End Sub


This code is located in "module 1"

Private dTime As Date
Sub MyMacro()
dTime = Now + TimeValue("00:0:03")
Application.OnTime dTime, "MyMacro"

Calculate


Application.DisplayFullScreen = True
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Try:

If ActiveWorkbook.Name = ThisWorkbook.Name Then Application.DisplayFullScreen = True
 
Upvote 0
Great I will try this tomorrow and it looks like it should work for my full screen issue but is there a way I can apply that to the auto update ever 3 seconds feature too?

Thanks in advance!!!!!!!
 
Upvote 0
Code:
Private dTime As Date

Sub MyMacro()

  dTime = Now + TimeValue("00:00:03")
  Application.OnTime dTime, "MyMacro"

  If ActiveWorkbook.Name <> ThisWorkbook.Name Then Exit Sub 

  Calculate

  Application.DisplayFullScreen = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,778
Messages
6,126,841
Members
449,343
Latest member
DEWS2031

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