Results 1 to 8 of 8

How can I activate the sheet that is running code from a VBA module?

Threaded View

mick86 How can I activate the sheet... 08-15-2012, 12:20 PM
xladept Re: How can I activate the... 08-15-2012, 12:36 PM
mick86 Re: How can I activate the... 08-15-2012, 01:01 PM
xladept Re: How can I activate the... 08-15-2012, 02:00 PM
mick86 Re: How can I activate the... 08-15-2012, 02:18 PM
xladept Re: How can I activate the... 08-15-2012, 07:08 PM
mick86 Re: How can I activate the... 08-18-2012, 06:09 AM
xladept Re: How can I activate the... 08-18-2012, 01:24 PM
  1. #1
    Registered User
    Join Date
    05-05-2009
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    68

    Question How can I activate the sheet that is running code from a VBA module?

    Hi

    This will hopefully be fairly straight forward.

    I would like to reference the current worksheet in vba code so that I can activate the sheet that is running the code. I need to do this as I am switching between 2 wordbooks and the workbook name in 1 instance is not fixed.

    I tried retrieving the workbook name like this:

    Function WorkbookName() As String
    WorkbookName=ThisWorkbook.Name
    End Function
    but could not work out how to implement that in code such as:

    Windows("filepath.xlsm").Activate
    Windows.WorkbookName.Activate
    The above does not work and I tried a few variations

    I did not know how to deal with the quotation marks and parenthesis.


    I have another option, the workbook name is contained in a cell on a worksheet within the workbook, the name is in text form minus the .xlsm part so this might be of use.



    Can anybody possibly help me achieve the desired outcome?



    Many thanks in advance, your wisdom is always appreciated.

    Regards,

    Michael.
    Last edited by mick86; 08-15-2012 at 12:22 PM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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