Home > Software engineering >  VBA, realizes the function by table 1 print module, to repeat print, obtain the data in table 2 in t
VBA, realizes the function by table 1 print module, to repeat print, obtain the data in table 2 in t

Time:09-16

Private Sub CommandButton1_Click ()
Dim Sh2 As Worksheet, myRng As Range, m % n %, i& , myC As New Collection
On the Error Resume Next
The Set Sh2=Sheet2
I=Sh2. [F65536]. End (xlUp). Row
Sh2. Range (F1: "O" & amp; 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" & amp; I). The AutoFilter Field:=1, Criteria1:=myC. Item (n)
M=Sh2. [F65536]. End (xlUp). Row
[K3]="" & amp; Sh2. Cells (m, "P")
[F3]="" & amp; Sh2. Cells (m, "G")
[I3]="" & amp; Sh2. Cells (m, "H")
[C3]="" & amp; Sh2. Cells (m, "I")
[C4]="" & amp; Sh2. Cells (m, "J")
[i2]="" & amp; Sh2. Cells (m, "Q")
[F4]="" & amp; Sh2. Cells (m, "R")
[A6: M10]=""
The Set myRng=Sh2. Range (" F2:0 "& amp; M) SpecialCells (xlCellTypeVisible)
MyRng. Copy (A6)
Sheet1. PrintOut
Next
Sh2. Range (S1: "O" & amp; I). The AutoFilter
End Sub


CodePudding user response:

Wish you a great god help to solve the problem that this is very simple, novice or a beginner, a little don't understand

CodePudding user response:

CodePudding user response:

reference 1st floor qq592798190 response:
wish you a great god help to solve the problem that this is very simple, novice or a beginner, a little don't understand



You are a beginner how know this question is very simple?

CodePudding user response:

On the Error Resume Next
It kills you, comment out this sentence and then ran to see if there is any error,
If there is no single step tracking error, every line see relevant variables is not what you want,

CodePudding user response:

reference little silence reply: 3/f
Quote: refer to 1st floor qq592798190 response:

Wish you a great god help to solve the problem that this is very simple, novice or a beginner, a little don't understand



You are a beginner how know this question is very simple?

Can't write, or at least look a little bit

CodePudding user response:

references 4 floor crispy ice cream response:
On Error Resume Next
It kills you, comment out this sentence and then ran to see if there is any error,
If there is no single step tracking error, every line see relevant variables is not what you want,

Has an error commented, Set myRng=Sh2. Range (" F2:0 "& amp; M) SpecialCells xlCellTypeVisible application-defined error
  •  Tags:  
  • VBA