Hey guys,
I am trying to write a macro that opens a workbook based on cell input from the current workbook.
Worksheets("Options Selector").Select
Name1 = Range("C19").Value
Name2 = Range("C18").Value
Workbook_name = """" & Name1 & "_" & Name2 & ".xls" & """"
Workbooks(Workbook_name).Worksheets("Summary").Range("B2:J33").Copy
But I get a subscript out of range error on the last line. It's because it's not accessing workbooks(workbook_name). Workbook_name should be "name1_name2.xls". I feel like i'm missing a built in VBA function to read the file and cannot just join strings like that to represent a file name.
I am trying to write a macro that opens a workbook based on cell input from the current workbook.
Worksheets("Options Selector").Select
Name1 = Range("C19").Value
Name2 = Range("C18").Value
Workbook_name = """" & Name1 & "_" & Name2 & ".xls" & """"
Workbooks(Workbook_name).Worksheets("Summary").Range("B2:J33").Copy
But I get a subscript out of range error on the last line. It's because it's not accessing workbooks(workbook_name). Workbook_name should be "name1_name2.xls". I feel like i'm missing a built in VBA function to read the file and cannot just join strings like that to represent a file name.