怎样把查询的数据 导入Excel 表中的 Sheet1
Dim i As Integer, j As Integer
Dim myexcel As New Excel.Application '定义一个新的Excel对象
Dim mybook As New Excel.Workbook '定义一个新的BOOK对象
Dim mysheet As New Excel.Worksheet '定义一个新的SHEET对象
Set mybook = myexcel.Workbooks.Add '添加一个新的BOOK
Set mysheet = mybook.Worksheets.Add '添加一个新的SHEET
Set mysheet = mybook.Worksheets(1) '设置活动工作表
For i = 1 To Adodc1.Recordset.RecordCount
For j = 1 To Adodc1.Recordset.Fields.Count
mysheet.Cells(i , j) = Adodc1.Recordset.Fields.Item(j - 1).Value
Next j
Adodc1.Recordset.MoveNext
Next i
myexcel.Visible = True
这段代码导入到Sheet1中,请问如何修改导入Excel 表中的 Sheet1
[解决办法]
去掉Set mysheet = mybook.Worksheets.Add '添加一个新的SHEET