|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub main()
Dim Sht1 As Worksheet, Sht2 As Worksheet
Dim LastRow1 As Long, LastRow2 As Long
Set Sht1 = Worksheets("表1")
Set Sht2 = Worksheets("表2")
j = 2
LastRow1 = Sht1.Cells(Rows.Count, 1).End(xlUp).Row
For n = 1 To LastRow1
If (VBA.Right(Sht1.Cells(n + 1, 1), 1) = "T" Or VBA.Right(Sht1.Cells(n + 1, 1), 1) = "W") And Sht1.Cells(n + 1, 2) > 0 Then
Sht2.Cells(j, 1) = Sht1.Cells(n + 1, 1)
Sht2.Cells(j, 2) = Sht1.Cells(n + 1, 2)
j = j + 1
End If
Next
'*******对结果进行升序排序
LastRow2 = Sht2.Cells(Rows.Count, 1).End(xlUp).Row
Range("A2:B" & LastRow2).Select
'Range("B24").Activate
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
:=xlPinYin, DataOption1:=xlSortNormal
End Sub |
评分
-
1
查看全部评分
-
|