+ Reply to Thread
Results 1 to 8 of 8

How to Make Current Open Worksheet as Active

  1. #1
    Registered User
    Join Date
    08-02-2013
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    41

    Post How to Make Current Open Worksheet as Active

    Hi All - I have a macro that's importing data from other Excel sheet only if the sheet name (Ex: Sheet1) is same as its referring in Macro (Sheet1), But the Sheet name is keep changing (Ex: Sheet4). Can anyone please share how to pick the name of the current tab on Source sheet (Source Excel) and use it in existing macro.

    Sorry if the quesiton isn't clear enough.

    Thanks in Advance,

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: How to Make Current Open Worksheet as Active

    Hi, momer,

    that should be ActiveSheet.Name or more Workbooks("YourWorkbook.xlsx").ActiveSheet.Name

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    08-02-2013
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: How to Make Current Open Worksheet as Active

    Macro is fetching the name of the file using the Input Box and not sure how Can I use activesheet in below Code.
    Please Login or Register  to view this content.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: How to Make Current Open Worksheet as Active

    Hi, momer,

    from what I understand you will use the same Sheetname in both workbooks:
    Please Login or Register  to view this content.
    If you just want to rely on the ActiveSheet in the opened workbook:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    08-02-2013
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: How to Make Current Open Worksheet as Active

    Hi Holger - Thanks for such a prompt response. The below code is making the current active sheet i.e Sheet1 as Active and copying the data over to another sheet. But what I am looking for is a way to select a tab from Source file ( A sheet name: which user had saved at the time of closure) and use that sheet data data to copy over on existing open Sheet2.
    From the above code I posted, Currently its pulling the data from file: Sales_Data and Sheetname(Data_Sheet ) but the sheetname is keep changing and here I need help to select whatever sheet was active(when it had saved).

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: How to Make Current Open Worksheet as Active

    Hi, momer,

    could you please do me a favour and explain to me what you think the line
    Please Login or Register  to view this content.
    is doing and maybe what should be altered where - sorry but I have lost track on your description.

    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    08-02-2013
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: How to Make Current Open Worksheet as Active

    Apologies for not being so clear, If I am correct the above line is copying the data within the given range from active sheet to Wb1 sheet.
    When I ran the macro, It is copying the sheet1 data range on Sheet2. but what I am looking for is to pull the data from different excel file (here the Source sheet name varies everytime) on Sheet2 of the open file.

    Many thanks,
    Omer

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: How to Make Current Open Worksheet as Active

    Hi, momer,

    you should make clear if Sheet2 is the name displayed on the worksheet tab or the codename for the sheet In your code you have both used Worksheets(2) which would mean the second worksheet in the collection of worksheets as well as Worksheets("Sheet2"). So you could replace
    Please Login or Register  to view this content.
    by
    Please Login or Register  to view this content.
    Ciao,
    Holger

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA to Open File (filename contains current date) & copy Sheet to active workbook
    By jlstidham in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2013, 10:50 PM
  2. [SOLVED] Make Open Workbook Active Irrespective Of Name
    By OzTrekker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-18-2012, 10:07 PM
  3. Current cell position for a non Active worksheet
    By Wizz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-15-2009, 08:40 PM
  4. Replies: 1
    Last Post: 04-07-2006, 07:54 AM
  5. How to indicate that the current visible worksheet is the active o
    By George Furnell in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2006, 01:30 PM

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