+ Reply to Thread
Results 1 to 4 of 4

Set Wb = ThisWorkbook

Hybrid View

ATLGator Set Wb = ThisWorkbook 06-01-2012, 01:48 PM
jeffreybrown Re: Set Wb = ThisWorkbook 06-01-2012, 01:55 PM
ATLGator Re: Set Wb = ThisWorkbook 06-01-2012, 01:58 PM
jeffreybrown Re: Set Wb = ThisWorkbook 06-01-2012, 02:10 PM
  1. #1
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Atlanta
    MS-Off Ver
    Excel 2007
    Posts
    171

    Set Wb = ThisWorkbook

    Can somebody please direct me to a site that explains the use of "Wb" as in "Set Wb = ThisWorkbook"? I don't think I quite get this - are you simply naming the workbook that the macro is running from so Excel can differentiate between workbooks?

    Thanks

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Set Wb = ThisWorkbook

    This could be a start...

    http://www.cpearson.com/excel/DeclaringVariables.aspx

    Basically, you are declaring Wb as a variable and it is equal to this workbook, so yes, your definition would appear correct.

    It would we the same as for instance, declaing a specific worksheet...

    Sub dosomething()
        Dim ws As Worksheet
        Set ws = Sheets("Sheet1")
        ws.Range("A1").Font.Bold = True
    End Sub
    This code would only affect Range A1 on Sheet1
    HTH
    Regards, Jeff

  3. #3
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Atlanta
    MS-Off Ver
    Excel 2007
    Posts
    171

    Re: Set Wb = ThisWorkbook

    Great, thank you

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Set Wb = ThisWorkbook

    You're very welcome

+ 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