- ©«¤l
- 522
- ¥DÃD
- 36
- ºëµØ
- 1
- ¿n¤À
- 603
- ÂI¦W
- 0
- §@·~¨t²Î
- win xp sp3
- ³nÅ骩¥»
- Office 2003
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2012-12-13
- ³Ì«áµn¿ý
- 2021-7-11
|
¦^´_ 3# home1913
¸Õ¸Õ¬Ý:
- Option Base 1
- Option Explicit
- Private Sub CommandButton1_Click()
- Dim i, j, ¦C¼Æ, Barcode¼Æ, ì®w¦s¶q As Integer
- Dim code1, code2, Äæ¦W As String
- Dim findCell, findRng As Range
-
- Barcode¼Æ = [B1].End(xlDown).Row - 1
- '1. ´¡¤J»²§UÄæ ÄæA(¤â°Ê)
-
- '2. ±N ÄæC ³f¸¹¦X¨Ö, ¥B ÄæA ¶ñ¤J»¼¼W¼Æ¦C
- [C2].Resize(Barcode¼Æ, 1) = ""
- [E2].Resize(Barcode¼Æ, 1) = ""
- For i = 2 To Barcode¼Æ + 1
- Cells(i, 1) = i
- If Left(Cells(i, 2), 1) = "w" Then
- code1 = Left(Cells(i, 2), 7)
- Else
- code2 = Left(Cells(i, 2), 6)
- Cells(i, 3) = code1 & code2
- End If
- Next
-
- '3. «ö ¥DÁä ÄæC, ¦¸Áä ÄæA »¼¼W±Æ§Ç
- [A1].Resize(Barcode¼Æ + 1, 5).Sort _
- Key1:=Range("C1"), Order1:=xlAscending, _
- Key2:=Range("A1"), Order2:=xlAscending, _
- Header:=xlYes
-
- '4. «·s¼g¤J¤½¦¡, ¨¾¾Þ§@¤£¤p¤ß§R±¼¤½¦¡
- [F3] = "=MATCH(F2,G2:G7,0)" '0 ¡÷ºë½T¬d¸ß, ¤£¥i¬Ù²¤, Lookup_array ¥i¥H¨Ì¥ô·N¦¸§Ç±Æ¦C¡C
- [F6] = "=MATCH(F5,H1:L1,0)" '1 ¡÷¥i¬Ù²¤, §ä¨ìµ¥©ó©Î¶È¦¸©ó lookup_value ªºÈ, Lookup_array¥²¶·»¼¼W±Æ§Ç
- '-1¡÷¤£¥i¬Ù²¤, ·|§ä¨ìµ¥©ó©Î¤j©ó lookup_value ªº³Ì¤pÈ, Lookup_array¥²¶·»¼´î±Æ§Ç
- [F8] = "=INDEX(H2:L7,F3,F6)" '¶Ç¦^¬d¸ß½d³ò, ¦C»PÄæ ªº¥æ义ÂIªºÈ
-
- '¥H¤W¤T¦C¬° ®w¦sªí©T©w¤j¤p ¨Ï¥Î,
- 'Y ®w¦sªí©T©w¤j¤p ·|ÅÜ°Ê, ½Ð§ï¥Î¤U¦C¤¦C
- ' ¦C¼Æ = CStr([G1].End(xlDown).Row)
- ' Äæ¦W = Chr([G1].End(xlToRight).Column + 63)
- ' [F3] = "=MATCH(F2,G2:G" & ¦C¼Æ & ",0)"
- ' [F6] = "=MATCH(F5,H1:" & Äæ¦W & "1,0)"
- ' [F8] = "=INDEX(H2:" & Äæ¦W & "7,F3,F6)"
-
- '5. ¥Dµ{¦¡
- i = 1
- Do
- i = i + 1
- If Cells(i, 3) = "" Then GoTo done1:
- [F5] = Left(Cells(i, 3), 7) '±NBarcode¦s¨ì [F5], ¨Ñ MATCH ¬d¸ß"Äæ"¥Î
- [F2] = Right(Cells(i, 3), 6) '±N³f¸¹¦s¨ì [E2], ¨Ñ MATCH ¬d¸ß"¦C"¥Î
- '[F8] = ®w¦sªí¤¤ªº ®w¦s¶q
- Cells(i, 5) = [F8] - Cells(i, 4) '¦s¶q = ì®w¦s¶q - ¾P°â¶q
-
- '¦pªG ³f¸¹ «ÂÐ, ²Ä¤Gµ§¶}©l, «h
- If Cells(i, 3) = Cells(i + 1, 3) Then
- Do
- i = i + 1
- If Cells(i, 3) = "" Then GoTo done1:
- Cells(i, 5) = Cells(i - 1, 5) - Cells(i, 4) '¦s¶q = ¤W¤@µ§¦s¶q - ¾P°â¶q
- Loop Until i > Barcode¼Æ Or Cells(i, 3) <> Cells(i + 1, 3)
- End If
- Loop Until i > Barcode¼Æ
-
- done1:
- '6. «öì§Ç±Æ§Ç
- [A1].Resize(Barcode¼Æ + 1, 5).Sort _
- Key1:=Range("A1"), Order1:=xlAscending, _
- Header:=xlYes
- End Sub
½Æ»s¥N½X |
|