I am running a macro that uses "Application.FileDialog(MsoFileDialogType.msoFileDialogFilePicker)" to select a single workbook file and then open the selected workbook.

Cell A1 on Sheet1 of the workbook that is running the macro contains sheet names that can be selected from a drop-down list. I want to be able to use the sheet name that is in cell A1 to select that sheet in the newly opened workbook.

It's probably something simple, but I can't seem to get it to work. Any ideas?

like
Posting as :
works at
You are currently posting as works at

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

like

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!!!

like

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.

like

That's because you need a worksheet variable to refer to a worksheet.
What IBM1 said is the best approach

Related Posts

Do other firms have mandatory department meetings? Practice group meetings?

like

Hi All, what should be salary expectations for technology consultant from SAP with 7 yoe joining Deloitte?

like

Paralegal with 6 years of experience with Personal injury and Complex litigation. How can I get into Corporate law?

like

Curious - what do you want out of life? Why do you want that? What is your “why” and “how” for what you’re working towards?

like

Seeking an expert in self guided/self directed Roth IRA investment and rules/regulations. Looking for a consultant who can quickly identify if there will be any red flags in this transaction (for my dad). Thank you!

like

Has anyone tried Farm to People or another similar farm/produce subscription service? What are your thoughts/experiences/recommendations? does it work without a doorman

like

RIP John Lewis. Thank you for everything.

like

You’re on a flight with friend who is 10 rows behind you and had to check a bag. Do you meet at end of jetway or just go straight to baggage claim so you can use bathroom and be on way?

like

Anyone got their H1 restamped in Mexico recently? If so, how long is the wait for getting a date? Looking to get something in next 3-4 weeks. Also, can I travel to Mexico on expired H1 but valid 797?

Guys, any comments please
TIA

Post Photo
like
like

What are most company standards for vacation time and PTO for small companies? We do 10 days after 1 yr, 15 days after 2yrs 15days after 5yrs and 20 days after 10yrs. PTO is accrued monthly after your first 90 days. 40-45 hrs. average is full time, 30-35 hrs. average is part-time. Does this sound reasonable?

like

Good afternoon AMAZING Nurses and Happy Taco Tuesday! I'm new to fishbowl, but not new to recruiting. I'm looking for RN's to work in Clinton, MD, more specifically, Cath RN's. Comment if you are someone you know would be interested in this FT opportunity. Thanks!

like

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

like

(28y white male) If/when MBB asks for GRE/GMAT scores after someone has gone through B School, what do they look for? I’m choosing LBS, most likely to pursue entrepreneurship (previously made Forbes 30u30 for a startup), but I like to create options for myself. For MBB it seems they like GMAT of 700+. I thought my GRE of 324 was decent (higher than Wharton’s average of 322 last year), but the ETS converted score was only 680 gmat. This seems weird. Should I retake GRE or GMAT while I’m fresh?

like

Technology analyst salary range in Infosys?? Any idea guys

like

How much should I expect from Deloitte for azure data engineer role, 2+yoe,how much max fixed they can give & max variable % & joining bonus & relocation Bonus
Deloitte

like

what is the band 6 average salary in bofa?

like

IBM vs. Accenture for SAP Functional?
In terms of
1. Good Work
2. Long Term Career
3. New Learnings
4. WLB
5. Job Security

like

Additional Posts in Excel Genius

Does anyone know of a good excel training online (pivot tables…filters…) ? (Preferably free)

like

How would I create a bar graph that shows same store sales growth for 5 products that were promoted during different time periods?

like

Anyone ever dealt with grouped rows / columns inexplicably stopping working? I have a big and pretty important model which uses grouped rows a lot (to click the plus and pop out more detail), and yesterday I opened it and it’s just all hidden instead of grouped. Any ideas how to fix?

like

Any macro experts that can help changing this 3 generation family tree generator to a 6 generation one (template link provided in comment below)? Provided by Microsoft but I have no idea how to edit this macro to allow more generations, and this is the easiest to generate template I've seen unfortunately

like

Anyone have recommendations for a 5 year forecast model and/or template for a private company? (For a small fintech company)

like

Not Excel but Outlook: anyone know how to make it so others can’t recall messages from your inbox?

like

Does anyone have experience setting up automated queries on Excel for Mac? I am trying to automate a paid search pacing document but am running into an issue with the Excel Power Query not being able to log in to Search Ads 360.

like

Does anybody have a link to download the tts turbo macro? Sad that you can't download it anymore :/

like

Trying to count the maximum number of overlaps in at a given time in a series of date ranges. Finding an overlap is easy, but not sure how to cycle through date ranges while keeping a Max count

like

Help!! Time-sensitive:
Please tell me how I can achieve this:

To create concatenation of every possible combination of Type to Price for every ID.
I provided an example below with the outcome I want in the second table. Would prefer if this be down without a macro.

Post Photo
like

I have a column of numbers with a “Special” format. I need these to be a date but when I select the date option from the drop down in the number dialog box it returns as all hashtags. I tried date value, substitute functions etc but nothing seems to work. Any suggestions?

like

I’m trying to do a crosswalk of sorts. Look up a GL account number in one cell in an array and bring back a number from a specified column. Not having great luck with a vlookup. Can’t remember the exact rules (order, etc.) is there an easier way?

like

What's the equivalent to a sumifs formula but instead of #s I want to bring in names. For example, i want to return a client name but only if it meets two criteria.

like

My company has locked down our Excel so that we can no longer access the VBA Editor (it’s greyed out and Alt F11 doesn’t work). However I can still access the Word VBA Editor. Is there a creative way I can launch the Excel VBA editor via the Word version, or somehow run Excel VBA code via the Word version?

likehelpful

Hi! I am working on creating a Poshmark and want hoping someone could help me with a formula for excel. Here is Postmarks fee range:

After your item sells, we deduct a small fee from the final order price. For sales under $15, the fee is a flat rate of $2.95. For sales above $15, the fee is 20% and you keep 80%.

Photo attached is an example.

I was thinking an IF/THEN formula but would love someones help. Thanks! :) #excel

Post Photo
like

Our group is exploring Alteryx. When I review im Excel, I can click on a cell to verify the formula. In Alteryx, I will get a hard coded Excel sheet. What are some ideas to make Alteryx reviewable?

like

Looking to use an XIRR formula with an “As of” date option (as of 12/31, 9/30, etc…) So it would essentially stop pulling dates and values once it hits the date in the “as of” date cell.

Any ideas? Much appreciated.

like

Can anyone recommend good learning resources for excel? I’ve used it for years and am familiar with all the vlookups & index matches but would like to grow my skills beyond that... TIA

like

I love this bowl. Sorry, continue to share nerdy excel shortcuts which I loooovee.

like

I know this is for excel, but any Tableau experts here can let me know how to present my mixed (countries, states, provinces) data on a map. I’ve tried dual axis but still not where I want it to be.

like

New to Fishbowl?

Download the Fishbowl app to
unlock all discussions on Fishbowl.
That was just a preview…
Sign Up to see all discussions
  • Discover what it’s like to work at companies from real professionals
  • Get candid advice from people in your field in a safe space
  • Chat and network with other professionals in your field
Sign up in seconds to unlock all discussions on Fishbowl.

Already a user?
Login here

Share

Embed this post

Copy and paste embed code on your site

Preview

Download the
Fishbowl app

See what’s happening in your industry
from the palm of your hand.

A phone with Fishbowl app

Scan your QR code to download
Fishbowl app on your mobile

Download app

Sign up for free to view this conversation on Fishbowl

By continuing you agree to Terms of Use and Privacy Policy

Already have an account? Log in

Sign up for free to continue using Fishbowl

By continuing you agree to Terms of Use(New) and Privacy Policy(New)
Messaging rates may apply

Already have an account? Log in

For account settings, visit Fishbowl on Desktop Browser or

General

Legal