Related Posts
RIP John Lewis. Thank you for everything.
Guys, any comments please
TIA
How much will it take for a AWS tech stack person with 6 yoe and 7a band with 13 lpa to find a project , i joined this month 15th in IBM kindly let me know. Comments will be very helpful for me as i am in bench now and i m hwaring staying in bench in IBM fornlong is not r8
Infosys Tata Consultancy Tech Mahindra Wipro Cognizant Capgemini
what is the band 6 average salary in bofa?
Additional Posts in Excel Genius
New to Fishbowl?
unlock all discussions on Fishbowl.
Don’t use activeworkbook. Set a variable = opening the file path of the selected workbook
Ex.
Set newWB = workbooks.open(filepath)
Then you can work with the worksheet with something like (assuming you store the ws name in a variable):
newWB.sheets(worksheetName).select
Success!!! I was able to get the following code to do exactly what I wanted:
Sub SelectSheetFromCellContent()
Dim shtName As String
Dim wb As Workbook
Sheet1.Select
shtName = Range("A1").Value
Set wb = Workbooks.Open("C:\Users\lwolf\Desktop\Testing\Template.xlsx")
wb.Sheets(shtName).Visible = True
Sheets(shtName).Select
Range("A1").Select
End Sub
Thanks again!!!
Since you are working with two different workbooks you will need to make sure the macro knows what workbook you are referring to when selecting the sheet. I would guess right now the macro is trying to select the sheet in the same file and not the newly opened file which probably doesn’t work because the file doesn’t have the sheet name.
That's because you need a worksheet variable to refer to a worksheet.
What IBM1 said is the best approach