I am trying to combine to of out excel lists into 1 worksbook with 2 sheet tabs. We have modified our ebs file to map the information from 1 sheet, and now we would like to mapp additional information by using the sane technique (line number) from a second sheet. I am struck. Anyone have any ideas. I will post what i currently have now.
Public Function PCF_WRITEFROM_XLS () As Integer
Dim nStat As Integer
Dim compID As At_ComponentID
Dim fieldvalues(50) As String
Dim i As Integer
Dim excelfilename As String
Dim linenumber As String
excelfilename = "C:\temp\123.xlsx"
nStat = at_Component_getCurrID(compID)
nStat = at_component_getString(fieldvalues(1), compID, "LINENUMBER")
linenumber = fieldvalues(1)
Call ReadExcel(excelfilename, linenumber, fieldvalues)
For i = 0 To 50
If (nstat = at_success) And (fieldvalues(i) <> "") Then
nStat = at_XchgWritelnText (" ATTRIBUTE"+ cstr(i) + " " + fieldvalues(i))
End If
Next i
Pcf_writefrom_xls = nStat
End Function
Sub ReadExcel(filename As String, linenumber As String, fieldvalues() As String)
Dim ExApp As Object
Dim wkb1 As Object
Dim sheet1 As Object
Dim row1 As Object
Dim media As String
Dim i As Integer
Dim done As Integer
Dim check1 As String
Dim check2 As String
Dim check3 As String
Dim check4 As String
excelfile = filename
If excelfile <> "" Then
Set ExApp = CreateObject("Excel.Application")
Set wkb1 = ExApp.Workbooks.Open(filename)
wkb1.Activate
Set sheet1 = wkb1.Sheets(2)
Set sheet2 = wkb1.Sheets(3)
i = 0
Do
i = i + 1
Set row13 = sheet1.Rows(i)
check1 = linenumber
check2 = sheet1.rows(i).Cells(1)
If check1 = check2 Then 'if the first cell equals linenumber, do the rest
done = 1
fieldvalues(1) = linenumber 'LineNumber
fieldvalues(2) = row13.Cells(3) 'Unit/Area No.
i = 0
Do
i = i + 1
Set row13 = sheet2.Rows(i)
check2 = linenumber
check3 = sheet2.rows(i).Cells(1)
If check3 = check4 Then 'if the first cell equals linenumber, do the rest
done = 1
fieldvalues(3) = linenumber
fieldvalues(4) = row13.Cells(2)
fieldvalues(5) = row13.Cells(3)
End If
If i > 2000 Then 'bail incase there is never a match
done = 1
msgbox "Information Not Found"
End If
Loop Until done > 0.01
ExApp.Quit
Else
msgbox "ERROR: Can not find the linelist file" + filename
End If
End Sub