Sub robert()
Application.Run "robert1"
Application.Run "robert2"
End Sub
Sub robert1()
Sheet1.[K265536].ClearContents
X = Sheet1.[A65536].End(xlUp).Row
Y = Sheet1.[K65536].End(xlUp).Row
For M = 2 To X
If Sheet1.Cells(M, 1) = Sheet1.Cells(2, 7) Then
Sheet1.Cells(Y + 1, 11) = Sheet1.Cells(M, 1)
Sheet1.Cells(Y + 1, 12) = Sheet1.Cells(M, 2)
Y = Y + 1
End If
Next
End Sub
Sub robert2()
X = Sheet1.[A65536].End(xlUp).Row
Y = Sheet1.[K65536].End(xlUp).Row
For M = 2 To X
If Sheet1.Cells(M, 1) = Sheet1.Cells(3, 7) Then
Sheet1.Cells(Y + 1, 11) = Sheet1.Cells(M, 1)
Sheet1.Cells(Y + 1, 12) = Sheet1.Cells(M, 2)
Y = Y + 1
End If
Next
End Sub作者: rouber590324 時間: 2019-5-8 14:56
Sub robert()
Sheet1.[K265536].ClearContents
X = Sheet1.[A65536].End(xlUp).Row
Y = Sheet1.[K65536].End(xlUp).Row
For M = 2 To X
For K = 2 To 10
If Sheet1.Cells(M, 1) = Sheet1.Cells(K, 7) Then
Sheet1.Cells(Y + 1, 11) = Sheet1.Cells(M, 1)
Sheet1.Cells(Y + 1, 12) = Sheet1.Cells(M, 2)
Y = Y + 1
End If
Next
Next
End Sub作者: 准提部林 時間: 2019-5-11 11:55
可以用[進階篩選]
Sub 條件篩選()
Dim cRNG As Range
[I:J].Clear
Set cRNG = Range([G1], [G65536].End(xlUp))
If cRNG.Count = 1 Then Exit Sub
Range("A:B").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=cRNG, _
CopyToRange:=Range("I1:J1"), Unique:=False
End Sub