Message 1 of 2
Capturing multiple range in Excel from AutoCAD VBA
Not applicable
11-24-1999
06:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a project I am working on which in AutoCAD VBA which needs to read in
the information contained in a multiple range. The following is my code:
Set ExcelApp = GetObject(, "Excel.Application")
If Err Then
Err.Clear
Set ExcelApp = CreateObject("Excel.Application")
If Err Then
MsgBox Err.Description, vbCritical, "Warning"
Exit Function
End If
End If
On Error GoTo 0
Set ExcelWorkbook = ExcelApp.Workbooks.Open(Temp)
Set ExcelWorkbook = ExcelApp.ActiveWorkbook
rangeArray = ExcelWorkbook.worksheets("Output").Range("F37:F60")
ExcelApp.Application.Quit
The above code works fine capturing the values of the range F37:F60. I need
the range F37:F60 plus the cells F10 and B3 in the same array. I can create
a named range in the spreadsheet called Range1 that is defined as
=Output!$F$37:$F$60,!Output$F$10,!Output$B$3. I have attempted the
following code based on examples in the Excel VBA help file, but neither of
them work:
rangeArray = ExcelWorkbook.worksheets("Output").Range("F37:F60,F10,B3")
rangeArray = ExcelWorkbook.worksheets("Output").Range("Range1") 'Range1
defined as above
Each of the above lines only returns the range F37:F60.
Any help or suggestions at all would be very much appreciated. TIA
Michael Teague
CADD Support Technician
Matrix Service, Inc.
the information contained in a multiple range. The following is my code:
Set ExcelApp = GetObject(, "Excel.Application")
If Err Then
Err.Clear
Set ExcelApp = CreateObject("Excel.Application")
If Err Then
MsgBox Err.Description, vbCritical, "Warning"
Exit Function
End If
End If
On Error GoTo 0
Set ExcelWorkbook = ExcelApp.Workbooks.Open(Temp)
Set ExcelWorkbook = ExcelApp.ActiveWorkbook
rangeArray = ExcelWorkbook.worksheets("Output").Range("F37:F60")
ExcelApp.Application.Quit
The above code works fine capturing the values of the range F37:F60. I need
the range F37:F60 plus the cells F10 and B3 in the same array. I can create
a named range in the spreadsheet called Range1 that is defined as
=Output!$F$37:$F$60,!Output$F$10,!Output$B$3. I have attempted the
following code based on examples in the Excel VBA help file, but neither of
them work:
rangeArray = ExcelWorkbook.worksheets("Output").Range("F37:F60,F10,B3")
rangeArray = ExcelWorkbook.worksheets("Output").Range("Range1") 'Range1
defined as above
Each of the above lines only returns the range F37:F60.
Any help or suggestions at all would be very much appreciated. TIA
Michael Teague
CADD Support Technician
Matrix Service, Inc.