用vb向excel添加数据的一个问题
我读取数据的代码是:
Dim row As Integer
Dim xlApp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
Set xlbook = xlApp.Workbooks.Open("C:\ouwei.xls")
Set xlsheet = xlbook.Worksheets(1)
row = 2
Do Text1.Text > "0"
If Text1.Text = xlsheet.Cells(row, 1) Then
Text2.Text = xlsheet.Cells(row, 2)
Text3.Text = xlsheet.Cells(row, 3)
Text4.Text = xlsheet.Cells(row, 4)
Text5.Text = xlsheet.Cells(row, 5)
Text6.Text = xlsheet.Cells(row, 6)
Text7.Text = xlsheet.Cells(row, 7)
Text8.Text = xlsheet.Cells(row, 8)
Text9.Text = xlsheet.Cells(row, 9)
Text10.Text = xlsheet.Cells(row, 10)
End If
row = row + 1
Loop
现在我想向这个excel文件添加数据,如果text1=(row,1)则弹出对话框“已有此编号”并不对数据进行操作,如果text1不等于(row,1),则向excel添加数据(判断数据有9行就在第10行添加,有10行就向第11行添加。。。类推,最多添加到第150行),谁能帮忙解决一下,谢谢!