用前不久求助按列中条件分配信息的代码修改后搞定!
Sub sc任务()
Dim myr%, m%, wb As Workbook, Rng As Range
myr = Range("b65535").End(3).Row
ar = Range("a1:t" & myr)
Set wb = Workbooks.Open("d:\sc\sc1.xlsm", Password:="123456")
With wb.Sheets("sc11")
m = Range("a1").End(3).Row
am = Range("a" & m).Value
Set Rng = ThisWorkbook.Sheets("任务表").Columns(1).Find(am, , , xlWhole)
If Rng Is Nothing Then
wb.Close: Exit Sub
Else
R = Rng.Row
End If
If myr = R Then wb.Close: Exit Sub
ReDim br(1 To myr, 1 To 16)
For i = R To myr
'If Val(Mid(ar(i, 15), 2, 1)) >= 2 Or Val(Mid(ar(i, 15), 3, 1)) >= 2 Then (原来用的条件)
n = n + 1
br(n, 1) = ar(i, 1)
br(n, 2) = ar(i, 2)
br(n, 3) = ar(i, 3)
br(n, 4) = ar(i, 4)
br(n, 5) = ar(i, 7)
br(n, 6) = ar(i, 8)
br(n, 7) = ar(i, 9)
br(n, 8) = ar(i, 10)
br(n, 9) = ar(i, 12)
br(n, 10) = ar(i, 13)
br(n, 11) = ar(i, 14)
br(n, 12) = ar(i, 15)
br(n, 13) = ar(i, 16)
br(n, 14) = ar(i, 17)
br(n, 15) = ar(i, 18)
br(n, 16) = ar(i, 20)
'End If
Next
.Range("a" & m).Resize(n, 16) = br
End With
wb.Close 1
Set wb = Nothing
MsgBox "sc分配完成"
End Sub
|