我想创建一个宏(将在之后分配给按钮),该宏在excel工作表中的表上执行以下操作(名为:细分)
该表包含9列,并且行数有所不同(与mysql表中的行数相同)。该表从“ B10”范围开始。
我目前有:
Public Sub download_nodes()
Dim pull As New QueryHandler
Dim rst As Recordset
Dim numRows As Integer
'Remove all current rows
Dim numRows As Integer
Dim schema As ListObject
Set schema = Sheets("CLH Breakdown").ListObjects("Schema")
numRows = schema.ListRows.Count
With schema
If numRows > 0 Then
schema.DataBodyRange.Offset(1,0).Resize(schema.DataBodyRange.Rows.Count - 1, .DataBodyRange.Columns.Count).Rows.Delete
End If
End With
'Get info from mysql
With pull
.ConnectionString = "localhost"
.SQLQuery = "SELECT * FROM `clh_bridge`.`clh_nodes_structure` ORDER BY NodeID;"
Set rst = .RetrieveQuery
End With
'I am missing how to resize the table and write the content there
End Sub
谢谢!