|
For i = 8 To 17
If Me.Range("D" & i).Value <> "" Then
Set DingW = Sh.Range("C" & Sh.Rows.Count).End(xlUp).Offset(1)
DingW.Value = Me.Range("N20")
TmpH = Application.WorksheetFunction.match(Me.Range("D" & i) & Me.Range("I" & i), Sheet2.Range("E:E") & Sheet2.Range("G:G"), 0)
DingW.Offset(, 1).Value = Sheet2.Range("B" & TmpH).Value
DingW.Offset(, 2).Value = Me.Range("B4").Value
DingW.Offset(, 3).Value = Me.Range("A" & i).Value
DingW.Offset(, 4).Value = Me.Range("D" & i).Value
DingW.Offset(, 5).Value = Me.Range("J" & i).Value
DingW.Offset(, 6).Value = Me.Range("H" & i).Value
DingW.Offset(, 7).Value = Me.Range("I" & i).Value
DingW.Offset(, 8).Value = Sheet2.Range("H" & TmpH).Value
DingW.Offset(, 9).FormulaR1C1 = "=rc[-3]*rc[-1]"
DingW.Offset(, 11).Value = Me.Range("O" & i).Value
End If
两个代码就算match函数参数变化,第一个代码不可以获得在第几行,第二个代码可以,感谢高手赐教
For i = 8 To 17
If Me.Range("D" & i).Value <> "" Then
Set DingW = Sh.Range("C" & Sh.Rows.Count).End(xlUp).Offset(1)
DingW.Value = Me.Range("N20")
TmpH = Application.WorksheetFunction.match(Me.Range("D" & i) , Sheet2.Range("E:E") , 0)
DingW.Offset(, 1).Value = Sheet2.Range("B" & TmpH).Value
DingW.Offset(, 2).Value = Me.Range("B4").Value
DingW.Offset(, 3).Value = Me.Range("A" & i).Value
DingW.Offset(, 4).Value = Me.Range("D" & i).Value
DingW.Offset(, 5).Value = Me.Range("J" & i).Value
DingW.Offset(, 6).Value = Me.Range("H" & i).Value
DingW.Offset(, 7).Value = Me.Range("I" & i).Value
DingW.Offset(, 8).Value = Sheet2.Range("H" & TmpH).Value
DingW.Offset(, 9).FormulaR1C1 = "=rc[-3]*rc[-1]"
DingW.Offset(, 11).Value = Me.Range("O" & i).Value
End If
|
|