tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,194
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
I have this code below which works great,
it copies data from one open workbook to another,
it checks if there are only the two workbooks open before runing, however i get a problem when someone has a personal workbok as well as stricktly speaking this is open
is i was woundering if we could somehow edit this code to say if personal workbook is open count should be 3 and copy all but personal?
heres the code
I have this code below which works great,
it copies data from one open workbook to another,
it checks if there are only the two workbooks open before runing, however i get a problem when someone has a personal workbok as well as stricktly speaking this is open
is i was woundering if we could somehow edit this code to say if personal workbook is open count should be 3 and copy all but personal?
heres the code
VBA Code:
Sub CopyData()
If Application.Workbooks.Count > 2 Then 'so this needs to be 3 if personal is in use!
MsgBox ("Too many documents open.")
Exit Sub
End If
Application.ScreenUpdating = False
Dim WB As Workbook
For Each WB In Workbooks ' except personal?
If WB.Name <> ThisWorkbook.Name Then
WB.ActiveSheet.UsedRange.Copy Sheets("raw data").Cells(1, 1)
End If
Next WB
Application.ScreenUpdating = True
End Sub