- ©«¤l
- 1018
- ¥DÃD
- 15
- ºëµØ
- 0
- ¿n¤À
- 1058
- ÂI¦W
- 0
- §@·~¨t²Î
- win7 32bit
- ³nÅ骩¥»
- Office 2016 64-bit
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ®ç¶é
- µù¥U®É¶¡
- 2012-5-9
- ³Ì«áµn¿ý
- 2022-9-28
|
¦^´_ 8# adam2010 - Sub Test()
- Dim rng As Range
- Dim s1 As Long, s2 As Long
- Dim cindex As Long
- With Sheets("¥X³f¤é")
- Set rng = .Range(.[A1], .[A1].End(xlToRight).End(xlDown).Offset(, -1)) '[¥X³f¤é]¸ê®Æ½d³ò
- End With
- For Each c In Sheets("¥æ´Á").Range("E2:E" & Sheets("¥æ´Á").[A1].End(xlDown).Row) '[¥æ´Á]¸ê®Æ¶ñ¤J½d³ò
- If c.Offset(, -4).Value <> c.Offset(-1, -4).Value Then
- cindex = 1
- s1 = 0 '²Ö¿n¦Ü«e¤@§å¼Æ¶q
- s2 = 0 '²Ö¿n¥X³f»Ý¨D¼Æ¶q
- Else
- s1 = s1 + c.Offset(-1, -1).Value
- End If
-
- Do While s2 <= s1
- cindex = cindex + 1
- If Application.IsError(Application.VLookup(c.Offset(, -4).Value, rng, cindex, False)) Then
- Exit Do
- Else
- s2 = s2 + Application.VLookup(c.Offset(, -4).Value, rng, cindex, False)
- End If
- Loop
-
- If s2 <= s1 Then
- c.Value = "NA"
- Else
- c.Value = rng.Cells(1, cindex).Value
- End If
- Next
- Set rng = Nothing
- End Sub
½Æ»s¥N½X |
|