Private Sub CommandButton1_Click()
Dim Sh2 As Worksheet, myRng As Range, m%, n%, i&, myC As New Collection
On Error Resume Next
Set Sh2 = Sheet2
i = Sh2.[F65536].End(xlUp).Row
Sh2.Range("F1:O" & i).Sort Key1:=Sh2.Range("F2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
:=xlPinYin
For n = 2 To i
myC.Add Sh2.Cells(n, "F"), CStr(Sh2.Cells(n, "F"))
Next
n = 0
For n = 1 To myC.Count
Sh2.Range("F1:O" & i).AutoFilter Field:=1, Criteria1:=myC.Item(n)
m = Sh2.[F65536].End(xlUp).Row
[K3] = " " & Sh2.Cells(m, "P")
[F3] = " " & Sh2.Cells(m, "G")
[I3] = " " & Sh2.Cells(m, "H")
[C3] = " " & Sh2.Cells(m, "I")
[C4] = " " & Sh2.Cells(m, "J")
[I4] = " " & Sh2.Cells(m, "Q")
[F4] = " " & Sh2.Cells(m, "R")
[A6:M10] = ""
Set myRng = Sh2.Range("F2:0" & m).SpecialCells(xlCellTypeVisible)
myRng.Copy [A6]
Sheet1.PrintOut
Next
Sh2.Range("S1:O" & i).AutoFilter
End Sub
Dim Sh2 As Worksheet, myRng As Range, m%, n%, i&, myC As New Collection
On Error Resume Next
Set Sh2 = Sheet2
i = Sh2.[F65536].End(xlUp).Row
Sh2.Range("F1:O" & i).Sort Key1:=Sh2.Range("F2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
:=xlPinYin
For n = 2 To i
myC.Add Sh2.Cells(n, "F"), CStr(Sh2.Cells(n, "F"))
Next
n = 0
For n = 1 To myC.Count
Sh2.Range("F1:O" & i).AutoFilter Field:=1, Criteria1:=myC.Item(n)
m = Sh2.[F65536].End(xlUp).Row
[K3] = " " & Sh2.Cells(m, "P")
[F3] = " " & Sh2.Cells(m, "G")
[I3] = " " & Sh2.Cells(m, "H")
[C3] = " " & Sh2.Cells(m, "I")
[C4] = " " & Sh2.Cells(m, "J")
[I4] = " " & Sh2.Cells(m, "Q")
[F4] = " " & Sh2.Cells(m, "R")
[A6:M10] = ""
Set myRng = Sh2.Range("F2:0" & m).SpecialCells(xlCellTypeVisible)
myRng.Copy [A6]
Sheet1.PrintOut
Next
Sh2.Range("S1:O" & i).AutoFilter
End Sub
解决方案 »
- vb.net 去除按钮上的焦点
- VB的ADODC问题
- VB请教【IDocHostShowUI】接口如何使用!
- 如何读取xml节点的属性
- 控件DataCombo1属情,在线等待!
- 如何实现库存的实时变更
- vb中調用crystal 9.0 做的報表﹐在客戶機上運行出錯﹖﹖
- 在VC中编译DLL并在VB中调用的问题
- vb+datareport 打印格式不正确问题,预览正确,在有的打印机上打印正确,而有的打印就出现格式不正确现象?
- what the distinguish between dim rst as new adodb.recordset and dim rst as new recordset?thank you!
- 如何用VB获取bin文件中的一段字节,并将其从16进制的gbk内码转换为汉字
- 关于AUTOCAD选择集问题
这句害死你了。把这句注释掉,然后跑起来看看有没有报错。
如果没有报错就单步跟踪,每一句都看看相关变量的值是不是你想要的。