Johnny Thunder
Well-known Member
- Joined
- Apr 9, 2010
- Messages
- 693
- Office Version
- 2016
- Platform
- MacOS
Hello all,
I have a macro I am working (see below). I have defined "varCellvalue" as a name of a Excel file in a cell which is a drop down list and "VarCell" as a Sheet name in every file of the drop down list so what I am trying to accomplish is that whatever a user selects as a file and a tab name the macro will open a specific file and specific sheet.
Currently the file will open but the specific sheet isn't working? any help or recode to help this would be greatly appreciated. Thanks all!!
Sub OpenWorkbook()
varCellvalue = Sheets("Main").Range("B23").Value
varCell = Sheets("Main").Range("B19").Value
If Not IsEmpty(Range("B23").Value) Then
Workbooks.Open "\\Lax-Netapp01\Dept_private\Business Systems\LFC MACRO TEST\" & varCellvalue & ".xlsm"
Sheets(" & VarCell & ").Activate
Else
Workbooks.Open "\\Lax-Netapp01\Dept_private\Business Systems\LFC MACRO TEST\" & varCellvalue & ".xls" Sheets(" & VarCell & ").Activate
End If
End Sub
I have a macro I am working (see below). I have defined "varCellvalue" as a name of a Excel file in a cell which is a drop down list and "VarCell" as a Sheet name in every file of the drop down list so what I am trying to accomplish is that whatever a user selects as a file and a tab name the macro will open a specific file and specific sheet.
Currently the file will open but the specific sheet isn't working? any help or recode to help this would be greatly appreciated. Thanks all!!
Sub OpenWorkbook()
varCellvalue = Sheets("Main").Range("B23").Value
varCell = Sheets("Main").Range("B19").Value
If Not IsEmpty(Range("B23").Value) Then
Workbooks.Open "\\Lax-Netapp01\Dept_private\Business Systems\LFC MACRO TEST\" & varCellvalue & ".xlsm"
Sheets(" & VarCell & ").Activate
Else
Workbooks.Open "\\Lax-Netapp01\Dept_private\Business Systems\LFC MACRO TEST\" & varCellvalue & ".xls" Sheets(" & VarCell & ").Activate
End If
End Sub