Computer Aided Automation

Full Version: AutoCAD VBA Sample code to get data from excel file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Function getfromexcel()
Dim i As Integer
Dim j As Integer

Dim excelfil As String
excelfile = "D:\CAA DEMO\Excel Worksheet.xlsx"

Dim objExcel As New Excel.Application
Dim worksheetName As String
Dim exWb As Excel.Workbook
Set exWb = objExcel.Workbooks.Open(excelfile)
For i = 1 To 1000
If exWb.Sheets("Sheet1").Cells(i, 1) <> "" Then
i = i + 1
total = i
End If

For i = 1 To total
A(i) = exWb.Sheets("Sheet1").Cells(i, 1)
B(i) = exWb.Sheets("Sheet1").Cells(i, 2)
Set exWb = Nothing
End Function