求助:一个Excel工作簿有多个表,如何才能把符合条件的数据写入到同名表中
Dim i As IntegerDim j As Integer
Dim Named As String
MSHFlexGrid1.Redraw = False
Set xlApp = CreateObject("Excel.Application")
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(App.Path & "\DATA\DATA.xls")
xlApp.Visible = True
For i = 1 To 8
Named = xlBook.Worksheets(i).Name
Next i
If Named = Text4.Text Then
Set xlSheet = xlBook.Worksheets("Named")
For i = 0 To MSHFlexGrid1.Rows - 1
For j = 0 To MSHFlexGrid1.Cols - 1
MSHFlexGrid1.Row = i
MSHFlexGrid1.Col = j
xlBook.Worksheets("Named").Cells(i + 1, j + 1) = Trim(MSHFlexGrid1.TextMatrix(i, j))
Next j
Next i
End If
MSHFlexGrid1.Redraw = True
这是我写的代码运行后并没数据写入望各位大佬帮忙修改一下。