How can I include a workbook name when specifying a Range in VBA code?
Thanks,
Keith
How can I include a workbook name when specifying a Range in VBA code?
Thanks,
Keith
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
>
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
>>
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks