I am a newer user of Excel VBA. I have been checking through all the other questions on here to try to solve my problem. I created a Master workbook, which copies info from 3 template spreadsheets when I run the macro. On my computer, it works correctly. However, when we tried to run it on a coworker's computer with the exact same 4 workbooks open, we ran into the "Subscript out of range" error.
I used the below code from this post (Out of range error for Windows().Activate) to check the names of all the open workbooks. Only 1 of the 4 (Master.xlsm) open workbooks displayed when I ran the code on my coworker's computer. On my computer, it displays 4 out of 4 open workbooks when I run that code
dim oBook as workbook
for each obook in workbooks
debug.print ">" & obook.name & "<"
next
Below are the first lines in my code. It breaks on the first line because it can't find the template workbook even though we have it open. When we run the above code on my coworker's computer during debugging, the Template1.xlsx workbook is not listed. I am not sure what is going wrong, and would really appreciate any help on this.
Sub Copy_To_Master()
Workbooks("Template1.xlsx").Worksheets("1").Range("A65:E104").Copy
Workbooks("Master.xlsm").Worksheets("1").Range("A65:E104").PasteSpecial Paste:=xlPasteValues
End Sub
Workbooks
collection. – BigBen