+ Reply to Thread
Results 1 to 10 of 10

VBA command switch between worksheets / tabs without names

  1. #1
    Forum Contributor Jack7774's Avatar
    Join Date
    08-31-2012
    Location
    Georgia, US
    MS-Off Ver
    Excel 2010
    Posts
    576

    Question VBA command switch between worksheets / tabs without names

    I export data from Oracle and each time I export the export file name and tab is named something different. So I can't write a macro to select a tab to rename it when the tab name is different each time a new export is done from Oracle. What I want is to write a VBA code to rename the worksheet's or tab's name to "OR" without quotation marks.

    or another option would be;

    Since I wasn't able to rename the tab using VBA because it would require knowing the name of the file, so instead I modified my macro to create a new worksheet called sheet1 and attempted to copy the data from the other tab using the previous tab command/function (unsure what the correct terminology to use here). Unfortunately, it failed to go to the previous tab because I can't click the tab using create macro because it would write a vba script with the exact name of the oracle created tab that changes each time. So is there a VBA script that switches between tabs without having to click it and without knowing the name of the worksheet or tab?

    Answer both if you don't mind.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA command switch between worksheets / tabs without names

    How can you open the exported file if you don't know it's name?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor Jack7774's Avatar
    Join Date
    08-31-2012
    Location
    Georgia, US
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: VBA command switch between worksheets / tabs without names

    I open it manually through the prompt from exporting it. So the file name is not an issue just the tab / worksheet name.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA command switch between worksheets / tabs without names

    How many sheets are there in the workbook and how many have data?

  5. #5
    Forum Contributor Jack7774's Avatar
    Join Date
    08-31-2012
    Location
    Georgia, US
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: VBA command switch between worksheets / tabs without names

    Just one sheet imports to excel.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA command switch between worksheets / tabs without names

    You can refer to that sheet as Worksheets(1).
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor Jack7774's Avatar
    Join Date
    08-31-2012
    Location
    Georgia, US
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: VBA command switch between worksheets / tabs without names

    I will test it out and get back to you tomorrow. Thanks for responding so quickly.

  8. #8
    Forum Contributor Jack7774's Avatar
    Join Date
    08-31-2012
    Location
    Georgia, US
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: VBA command switch between worksheets / tabs without names

    Thisworkbook.worksheets(1).Name = "OR" didn't work for me but Activeworksheet.name = "OR" did. Thank you for your help.

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA command switch between worksheets / tabs without names

    Just out of curiousity what did the code I suggested do?

    Did it rename the wrong worksheet in the wrong workbook?

  10. #10
    Forum Contributor Jack7774's Avatar
    Join Date
    08-31-2012
    Location
    Georgia, US
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: VBA command switch between worksheets / tabs without names

    It did not work or even run.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1