<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Capturing multiple range in Excel from AutoCAD VBA in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/capturing-multiple-range-in-excel-from-autocad-vba/m-p/339737#M98298</link>
    <description>I have a project I am working on which in AutoCAD VBA which needs to read in&lt;BR /&gt;
the information contained in a multiple range.  The following is my code:&lt;BR /&gt;
&lt;BR /&gt;
    Set ExcelApp = GetObject(, "Excel.Application")&lt;BR /&gt;
&lt;BR /&gt;
    If Err Then&lt;BR /&gt;
        Err.Clear&lt;BR /&gt;
        Set ExcelApp = CreateObject("Excel.Application")&lt;BR /&gt;
        If Err Then&lt;BR /&gt;
            MsgBox Err.Description, vbCritical, "Warning"&lt;BR /&gt;
            Exit Function&lt;BR /&gt;
        End If&lt;BR /&gt;
    End If&lt;BR /&gt;
&lt;BR /&gt;
    On Error GoTo 0&lt;BR /&gt;
&lt;BR /&gt;
    Set ExcelWorkbook = ExcelApp.Workbooks.Open(Temp)&lt;BR /&gt;
&lt;BR /&gt;
    Set ExcelWorkbook = ExcelApp.ActiveWorkbook&lt;BR /&gt;
&lt;BR /&gt;
    rangeArray = ExcelWorkbook.worksheets("Output").Range("F37:F60")&lt;BR /&gt;
&lt;BR /&gt;
    ExcelApp.Application.Quit&lt;BR /&gt;
&lt;BR /&gt;
The above code works fine capturing the values of the range F37:F60.  I need&lt;BR /&gt;
the range F37:F60 plus the cells F10 and B3 in the same array.  I can create&lt;BR /&gt;
a named range in the spreadsheet called Range1 that is defined as&lt;BR /&gt;
=Output!$F$37:$F$60,!Output$F$10,!Output$B$3.  I have attempted the&lt;BR /&gt;
following code based on examples in the Excel VBA help file, but neither of&lt;BR /&gt;
them work:&lt;BR /&gt;
&lt;BR /&gt;
rangeArray = ExcelWorkbook.worksheets("Output").Range("F37:F60,F10,B3")&lt;BR /&gt;
&lt;BR /&gt;
rangeArray = ExcelWorkbook.worksheets("Output").Range("Range1") 'Range1&lt;BR /&gt;
defined as above&lt;BR /&gt;
&lt;BR /&gt;
Each of the above lines only returns the range F37:F60.&lt;BR /&gt;
&lt;BR /&gt;
Any help or suggestions at all would be very much appreciated.  TIA&lt;BR /&gt;
&lt;BR /&gt;
Michael Teague&lt;BR /&gt;
CADD Support Technician&lt;BR /&gt;
Matrix Service, Inc.</description>
    <pubDate>Wed, 24 Nov 1999 14:35:52 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>1999-11-24T14:35:52Z</dc:date>
    <item>
      <title>Capturing multiple range in Excel from AutoCAD VBA</title>
      <link>https://forums.autodesk.com/t5/vba-forum/capturing-multiple-range-in-excel-from-autocad-vba/m-p/339737#M98298</link>
      <description>I have a project I am working on which in AutoCAD VBA which needs to read in&lt;BR /&gt;
the information contained in a multiple range.  The following is my code:&lt;BR /&gt;
&lt;BR /&gt;
    Set ExcelApp = GetObject(, "Excel.Application")&lt;BR /&gt;
&lt;BR /&gt;
    If Err Then&lt;BR /&gt;
        Err.Clear&lt;BR /&gt;
        Set ExcelApp = CreateObject("Excel.Application")&lt;BR /&gt;
        If Err Then&lt;BR /&gt;
            MsgBox Err.Description, vbCritical, "Warning"&lt;BR /&gt;
            Exit Function&lt;BR /&gt;
        End If&lt;BR /&gt;
    End If&lt;BR /&gt;
&lt;BR /&gt;
    On Error GoTo 0&lt;BR /&gt;
&lt;BR /&gt;
    Set ExcelWorkbook = ExcelApp.Workbooks.Open(Temp)&lt;BR /&gt;
&lt;BR /&gt;
    Set ExcelWorkbook = ExcelApp.ActiveWorkbook&lt;BR /&gt;
&lt;BR /&gt;
    rangeArray = ExcelWorkbook.worksheets("Output").Range("F37:F60")&lt;BR /&gt;
&lt;BR /&gt;
    ExcelApp.Application.Quit&lt;BR /&gt;
&lt;BR /&gt;
The above code works fine capturing the values of the range F37:F60.  I need&lt;BR /&gt;
the range F37:F60 plus the cells F10 and B3 in the same array.  I can create&lt;BR /&gt;
a named range in the spreadsheet called Range1 that is defined as&lt;BR /&gt;
=Output!$F$37:$F$60,!Output$F$10,!Output$B$3.  I have attempted the&lt;BR /&gt;
following code based on examples in the Excel VBA help file, but neither of&lt;BR /&gt;
them work:&lt;BR /&gt;
&lt;BR /&gt;
rangeArray = ExcelWorkbook.worksheets("Output").Range("F37:F60,F10,B3")&lt;BR /&gt;
&lt;BR /&gt;
rangeArray = ExcelWorkbook.worksheets("Output").Range("Range1") 'Range1&lt;BR /&gt;
defined as above&lt;BR /&gt;
&lt;BR /&gt;
Each of the above lines only returns the range F37:F60.&lt;BR /&gt;
&lt;BR /&gt;
Any help or suggestions at all would be very much appreciated.  TIA&lt;BR /&gt;
&lt;BR /&gt;
Michael Teague&lt;BR /&gt;
CADD Support Technician&lt;BR /&gt;
Matrix Service, Inc.</description>
      <pubDate>Wed, 24 Nov 1999 14:35:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/capturing-multiple-range-in-excel-from-autocad-vba/m-p/339737#M98298</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-11-24T14:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing multiple range in Excel from AutoCAD VBA</title>
      <link>https://forums.autodesk.com/t5/vba-forum/capturing-multiple-range-in-excel-from-autocad-vba/m-p/339738#M98299</link>
      <description>Hi! Michael,&lt;BR /&gt;
&lt;BR /&gt;
I dont know why it doesn't work in your case.&lt;BR /&gt;
I have the following code which essentially does the same thing and it works&lt;BR /&gt;
fine in A2K.&lt;BR /&gt;
Could remove "On Error go to 0 and check what trap the error(if at all error&lt;BR /&gt;
is generated)?&lt;BR /&gt;
&lt;BR /&gt;
'______________________________&lt;BR /&gt;
Sub f_selectRange()&lt;BR /&gt;
Dim po_xl As Application&lt;BR /&gt;
Dim po_ws As Worksheet&lt;BR /&gt;
Dim po_rg As Range&lt;BR /&gt;
&lt;BR /&gt;
'keep the excel open to run this&lt;BR /&gt;
Set po_xl = GetObject(, "Excel.Application")&lt;BR /&gt;
&lt;BR /&gt;
'select multiple cells&lt;BR /&gt;
Set po_ws = po_xl.Worksheets("Sheet2")&lt;BR /&gt;
po_ws.Activate&lt;BR /&gt;
Set po_rg = po_ws.Range("A1:A10,F1:F3,B10")&lt;BR /&gt;
po_rg.Select&lt;BR /&gt;
End Sub&lt;BR /&gt;
'______________________________&lt;BR /&gt;
&lt;BR /&gt;
--&lt;BR /&gt;
bye,&lt;BR /&gt;
&lt;BR /&gt;
P.Murali&lt;BR /&gt;
Michael Teague &lt;XMTEAGUE&gt; wrote in message&lt;BR /&gt;
news:81gt4p$8sb6@adesknews2.autodesk.com...&lt;BR /&gt;
&amp;gt; I have a project I am working on which in AutoCAD VBA which needs to read&lt;BR /&gt;
in&lt;BR /&gt;
&amp;gt; the information contained in a multiple range.  The following is my code:&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Set ExcelApp = GetObject(, "Excel.Application")&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; Michael Teague&lt;BR /&gt;
&amp;gt; CADD Support Technician&lt;BR /&gt;
&amp;gt; Matrix Service, Inc.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;/XMTEAGUE&gt;</description>
      <pubDate>Thu, 25 Nov 1999 05:02:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/capturing-multiple-range-in-excel-from-autocad-vba/m-p/339738#M98299</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-11-25T05:02:58Z</dc:date>
    </item>
  </channel>
</rss>

