05-15-2018
09:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
05-15-2018
09:11 AM
You can use a function like this:
Sub Main()
MultiValue.List("myFinishExt") = ReadValues("I:\Templates 2018\myFinishExt.xlsx", 1, 1, 2, 100)
MultiValue.List("myFinishInt") = ReadValues("I:\Templates 2018\myFinishInt.xlsx", 1, 1, 2, 100)
MultiValue.List("myMaterial") = ReadValues("I:\Templates 2018\myMaterial.xlsx", 1, 1, 2, 100)
End Sub
Private Function ReadValues(sExcelPath As String, Sheet As Integer, Column As Integer, StartRow As Integer, EndRow As Integer) As String()
Dim R() As String
Try
Dim Range As Integer = Abs(EndRow - StartRow)
Redim R(Range)
Dim oExcel As Object = CreateObject("Excel.Application")
oExcel.Visible = False
oExcel.DisplayAlerts = False
Dim oWB As Object = oExcel.Workbooks.Open(sExcelPath)
Dim oWS As Object = oWB.Sheets(Sheet)
oWS.Activate()
Dim j As Integer = 0
For i As Integer = StartRow To EndRow
R(j) = oWS.Cells(i, Column).Value
j += 1
Next
oWB.Close (True)
oExcel.Quit()
oExcel = Nothing
Catch
End Try
Return R
End Function
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods