|
楼主 |
发表于 2023-3-11 17:23
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 jian82372387 于 2023-3-11 17:26 编辑
Yalishanda30 发表于 2023-3-11 16:34
额。。。。代码有一处取错数据了
请问是第二次发的代码修改了哪里啊?因为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
具体哪一句出错啦?? |
|