1,217
社区成员




'Dim ExcelApp, oBook, a, c
Dim ExcelApp As Object ' As Excel.Application
Dim oBook As Object ' As Workbook
Dim xlsheet As Object ' As Worksheet
Dim a As String, c As String
'Dim i As Long, v As Long
Dim i As Long
Set ExcelApp = CreateObject("Excel.Application")
'Set oBook = ExcelApp.Workbooks.Open("d:\1.xls", missing, True)
Set oBook = ExcelApp.Workbooks.Open("d:\1.xls", False, True)
a = Text6 '表格名
Set xlsheet = oBook.Sheets(a)
'v = xlsheet.Range("B:B").Rows.Count
'For i = 1 To xlsheet.Range("B:B").Rows(v).End(xlUp).Row
' If (xlsheet.Cells(i, 2).Text = "32KP") Then
' Text1.Text = xlsheet.Cells(i, 5).Text
' Exit For
' End If
'Next
i = 2 ' 数据从第2行开始
Do
c = xlsheet.Cells(i, 2).Text
If (Len(c) = 0) Then Exit Do
If (c = "32KP") Then
Text1.Text = xlsheet.Cells(i, 5).Text
Exit Do
End If
i = i + 1 ' 指向下一行
Loop
'Dim ExcelApp, oBook, a, c
Dim ExcelApp As Object ' As Excel.Application
Dim oBook As Object ' As Workbook
Dim xlsheet As Object ' As Worksheet
Dim a As String, c As String
Dim i As Long, v As Long
Set ExcelApp = CreateObject("Excel.Application")
'Set oBook = ExcelApp.Workbooks.Open("d:\1.xls", missing, True)
Set oBook = ExcelApp.Workbooks.Open("d:\1.xls", False, True)
a = Text6 '表格名
Set xlsheet = oBook.Sheets(a)
v = xlsheet.Range("B:B").Rows.Count
For i = 1 To xlsheet.Range("B:B").Rows(v).End(xlUp).Row
If (xlsheet.Cells(i, 2).Text = "32KP") Then
Text1.Text = xlsheet.Cells(i, 5).Text
Exit For
End If
Next