+ Reply to Thread
Results 1 to 3 of 3

How can I include a workbook name when specifying a Range in VBA code?

Hybrid View

  1. #1
    keithb
    Guest

    How can I include a workbook name when specifying a Range in VBA code?

    How can I include a workbook name when specifying a Range in VBA code?

    Thanks,

    Keith



  2. #2
    Norman Jones
    Guest

    Re: How can I include a workbook name when specifying a Range in VBA code?

    Hi Heith,

    One way:

    Sub Tester08()
    Dim WB As Workbook
    Dim WS As Worksheet
    Dim Rng As Range


    Set WB = Workbooks("MyWorkBook")
    Set WS = WB.Sheets("MysheetName")
    Set Rng = WS.Range("A1:D100")

    End Sub



    ---
    Regards,
    Norman



    "keithb" <k31thb@yahoo.com> wrote in message
    news:eOP3QaXmFHA.2628@tk2msftngp13.phx.gbl...
    > How can I include a workbook name when specifying a Range in VBA code?
    >
    > Thanks,
    >
    > Keith
    >




  3. #3
    Norman Jones
    Guest

    Re: How can I include a workbook name when specifying a Range in VBA code?

    Hi Keith,

    Just to add, if the workbook has previously been saved, then you must
    include the extension (e.g.: .xls) in the workbook name.

    So:

    > Set WB = Workbooks("MyWorkBook")


    should be in the form:

    Set WB = Workbooks("MyWorkBook.xls")

    for a saved workbook.



    ---
    Regards,
    Norman



    "Norman Jones" <normanjones@whereforartthou.com> wrote in message
    news:Oo2p5hXmFHA.2860@TK2MSFTNGP15.phx.gbl...
    > Hi Heith,
    >
    > One way:
    >
    > Sub Tester08()
    > Dim WB As Workbook
    > Dim WS As Worksheet
    > Dim Rng As Range
    >
    >
    > Set WB = Workbooks("MyWorkBook")
    > Set WS = WB.Sheets("MysheetName")
    > Set Rng = WS.Range("A1:D100")
    >
    > End Sub
    >
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "keithb" <k31thb@yahoo.com> wrote in message
    > news:eOP3QaXmFHA.2628@tk2msftngp13.phx.gbl...
    >> How can I include a workbook name when specifying a Range in VBA code?
    >>
    >> Thanks,
    >>
    >> Keith
    >>

    >
    >




+ 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