+ Reply to Thread
Results 1 to 4 of 4

How to set your active workbook to a variable

  1. #1
    Registered User
    Join Date
    09-20-2012
    Location
    New york
    MS-Off Ver
    Excel 2003
    Posts
    45

    How to set your active workbook to a variable

    Hello I am getting an error when I try to set a variable to the active workbook can someone please explain why this error was generated.

    Below is the syntax I used Thank you

    Sub SetupTransfers()
    Dim MyBook As Workbook
    MyBook = ActiveWorkbook.Name
    end sub

  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 set your active workbook to a variable

    Hi, Darthzo,

    try it this way:
    Please Login or Register  to view this content.
    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
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: How to set your active workbook to a variable

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    09-20-2012
    Location
    New york
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: How to set your active workbook to a variable

    Thank you Norie and HaHoBe it worked!

+ 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