|
楼主 |
发表于 2023-3-11 17:32
|
显示全部楼层
请问第二次上传的代码修改了哪里啊??SQL没学过,请问一下如果数据源表里第一行表头上面插入了一个标题行,代码需要怎么修改才能正常正常运行啊??
Private clsSQL As ClassSQL
Private vData As Variant
Private vData_next As Variant
Private sSQL As String
Private Sub cmd_Printout_Click()
Dim print_cat As String
With Me
print_cat = .cb_list
If Len(print_cat) Then
If clsSQL Is Nothing Then Set clsSQL = New ClassSQL
sSQL = "SELECT [序号] FROM [数据源$] WHERE [性质]='" & print_cat & "'"
vData = clsSQL.GetDataBySQL(SQL:=sSQL, SqlType:="Excel", FileOrServer:=ThisWorkbook.FullName, OutputTitle:=False)
If IsArray(vData) Then
For i = 1 To UBound(vData)
Sheet1.Range("V4") = vData(i, 1)
Sheet1.Calculate
Sheet1.PrintOut Copies:=1, Collate:=True
Next
End If
End If
End With
End Sub
Private Sub UserForm_Initialize()
If clsSQL Is Nothing Then Set clsSQL = New ClassSQL
sSQL = "SELECT DISTINCT [性质] FROM [数据源$]"
vData = clsSQL.GetDataBySQL(SQL:=sSQL, SqlType:="Excel", FileOrServer:=ThisWorkbook.FullName, OutputTitle:=False)
Me.cb_list.Clear
Me.cb_list.List = vData
End Sub
|
|