Adjusting this macro that checks if too many workbooks are open to take into consideration the personal workbook etc

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

OK so i have a macro that runs to copy data from on one open document to another,
it works great but I want a safegauard that checks there are only two workbooks open the one with the macro and the one with the data to be copied
Now i have this code below, and it works great except some of use have our own Personal Workbook that stores macros so the check needs to be if personal is present check for 3 if not 2
any idea how i do this?

heres my code

VBA Code:
    If Application.Workbooks.Count > 2 Then
        MsgBox ("Too many documents open.")
        Exit Sub
    End If
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
May I suggest that you copy from a named workbook and paste to a second named workbook, rather than checking you have only workbooks(1) and workbooks(2) open?

If you share the code you use to copy and past we will be more specific on how coding that.

Bye
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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