On Nov 19, 9:39 pm, OssieMac <Ossie...@discussions.microsoft.com>
wrote:
> Hi again Steve,
>
> My last answer not quite right for your question. You indicated a named
> range in Data so use this instead.
>
> Sub test()
>
> Dim wbData As Workbook
> Dim wbModel As Workbook
> Dim rng As Range
>
> Set wbData = Workbooks("Data.xlsm")
> Set wbModel = ThisWorkbook
>
> With wbData.Sheets("Sheet1")
> Set rng = .Range("Drange")
> End With
>
> rng.Copy Destination:=wbModel.Sheets("Sheet1").Range("B1")
>
> End Sub
>
> --
> Regards,
>
> OssieMac
>
> "OssieMac" wrote:
> > Hi Steve,
>
> > See if this helps. Macro is in workbook Model and data is in workbook Data.
>
> > It copies from Data workbook to workbook Model:-
>
> > Sub test()
>
> > Dim wbData As Workbook
> > Dim wbModel As Workbook
> > Dim rng As Range
>
> > Set wbData = Workbooks("Data.xlsm")
> > Set wbModel = ThisWorkbook
>
> > Set rng = wbData.Sheets("Sheet1").Range("A1:A10")
>
> > rng.Copy Destination:=wbModel.Sheets("Sheet1").Range("B1")
>
> > End Sub
>
> > --
> > Regards,
>
> > OssieMac
>
> > "SteveM" wrote:
>
> > > This seems pretty trivial but it's not clear to me how to do refer to
> > > range object in an external source.
>
> > > I want to access and use a named Range in a second workbook. I'm
> > > thinking that I can declare a Range variable in my ActiveWorkbook and
> > > set that equal to the external range. So:
>
> > > Say the primary Workbook is Model.xls and the one I want to access is
> > > Data.xls, and the Data named Range is DRange
>
> > > So in a Model module
>
> > > Sub Something()
>
> > > Dim rng as Range
> > > Set rng = Workbooks("Data.xls")...Range("DRange")
>
> > > But I don't know how to finish the line.
>
> > > I know I'm not asking for clever, only mundane. But if you could help
> > > that would be great.
>
> > > Thanks,
>
> > > SteveM
Thanks very much guys, but I figured out this single line solution.
Set rng = Workbooks("Data.xls").Sheets("DataSheet").Range("DRange")
Note that the workbook is already open.
SteveM
P.S. I should read the documentation more often