该程序只输出符合“加号”状态的表单列表以及他们合格的日期。
我目前正在尝试确保没有合格的日期在相邻字段中输出“0”而不是表单的名称。当前程序不会这样做,并想知道我需要添加哪些命令。
Sub FilterPlusData()
Dim oWbk As Workbook
Dim oSht As Worksheet
Dim oShtDestiny As Worksheet
Dim iLoop As Integer
Dim iFirstRow As Integer
Dim iRows As Integer
Dim iRowDestiny As Integer
Set oWbk = ThisWorkbook
Set oShtDestiny = oWbk.Worksheets("OUTPUT")
iFirstRow = 4
For Each oSht In oWbk.Worksheets
If oSht.Name <> "OUTPUT" Then
If oSht.Range("$A$2").Value = "Date" Then
iRows = oSht.Cells(Rows.Count, 1).End(xlUp).Row
For iLoop = iFirstRow To iRows
If oSht.Cells(iLoop, 19).Value = "PLUS" Then
With oShtDestiny
iRowDestiny = .Cells(Rows.Count, 1).End(xlUp).Row + 1
.Cells(iRowDestiny, 1).Value = oSht.Cells(iLoop, 1).Value
.Cells(iRowDestiny, 2).Value = oSht.Name
End With
End If
Next iLoop
End If
End If
Next oSht
'Order Ascendent
iRowDestiny = oShtDestiny.Cells(Rows.Count, 1).End(xlUp).Row + 1
With oShtDestiny.Sort
.SetRange Range("$A$3:C" & iRowDestiny)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
答案 0 :(得分:2)
作为一个快速而肮脏的,为什么不只是在Else
语句中添加If
与您完全相同的内容,而是将行.Cells(iRowDestiny, 2).Value = oSht.Name
更改为{ {1}}?那不是你想要的吗?
.Cells(iRowDestiny, 2).Value = 0