- ©«¤l
- 354
- ¥DÃD
- 5
- ºëµØ
- 0
- ¿n¤À
- 387
- ÂI¦W
- 0
- §@·~¨t²Î
- windows7
- ³nÅ骩¥»
- vba,vb,excel2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2017-1-8
- ³Ì«áµn¿ý
- 2024-8-2
|
GPT4
¦b±z´£¨Ñªº¹Ï¤ù¤¤¡A¥ª°¼¬O¤@Ó¸ê®Æ¦Cªí¡A¥k°¼¬O¤@Ó¶×Á`µ²ªG¡C³oÓ¦Cªí¦ü¥G¬O¥Î©ó°l踪®w¦s©Î³f¬[¤Wªºª««~¡C³f¬[§Ç¸¹¦b¬Y¨Ç¦æ¬O¦X¨Öªº¡A¥B¦X¨Öªº¦æ¼Æ¤£©T©w¡C±z§Æ±æ¯à°÷¹³¥kÃä®i¥Üªº¨º¼Ë¡A³q¹L¿é¤J³f¬[§Ç¸¹¡Aª½±µ±N¬ÛÃö¸ê®ÆÂಾ¨ì¥k°¼¡C
´£¨Ñªº¥N½X¬O¤@Ó Excel §»¡A¥Î©ó³B²z³oºØÃþ«¬ªº¸ê®ÆÂಾ¡C¥N½X¶i¦æ¤F¦p¤U¾Þ§@¡G
½T©w¼Æ¾Ú½d³ò¡C
²M°£¥Ø¼Ð½d³ò¡]K2:U1000¡^ªº¤º®e¡C
¹M¾ú¯S©wªº¦C¡]K1, N1, Q1, T1¡^¡A³o¨Ç¦C¦ü¥G¬O¥Î¨Ó«ü©w¤£¦Pªº³f¬[§Ç¸¹¡C
¹ï©ó¨CÓ«ü©wªº³f¬[§Ç¸¹¡A¥N½X´M§ä¥ª°¼¦Cªí¤¤©Ò¦³¤Ç°tªº¦æ¡C
±N¤Ç°t¦æ¤¤ªº¸ê®Æ½Æ»s¨ì¥k°¼ªº¬ÛÀ³¦ì¸m¡C
pºâ¨Ã²K¥[Á`¼Æ¨ì³Ì«á¡C
ª`ÄÀ±zªº¥N½X¡A¥H«K©ó²z¸Ñ¨C¤@³¡¤Àªº¥\¯à¡G
vb
Copy code
Sub test()
' Àò¨ú³Ì«á¤@¦æªº¦æ¸¹
r = Cells(Rows.Count, 1).End(xlUp).Row
' ²M°£K2¨ìU1000½d³ò¤ºªº©Ò¦³¤º®e
Range("k2:u1000").ClearContents
' ¹M¾úK1, N1, Q1, T1³o¥|¦Cªº³æ¤¸®æ
For Each Z In Range("K1,N1,Q1,T1")
t5 = 0: t4 = 0 ' ªì©l¤ÆÅܶq
' ¦pªG·í«e³æ¤¸®æ¦³È
If Z.Value <> "" Then
' ¹M¾ú2¨ì³Ì«á¤@¦æ
For i = 2 To r
' ¦pªG·í«e¦CªºÈ»PC¦CªºÈ¬Û¦P¡]¤£°Ï¤À¤j¤p¼g¡^
If UCase(Z.Value) = UCase(Cells(i, 3).Value) Then
' ¹M¾ú¦X¨Ö°Ï°ìªº¨C¤@¦æ
For j = i To Cells(i, 3).MergeArea.Count + i - 1
t4 = t4 & "¡¶" & Cells(j, 4)
t5 = t5 & "¡¶" & Cells(j, 5)
tsum = tsum + Cells(j, 5)
Next
End If
Next
' ¤Á³Î¦r²Å¦êÀò¨ú¸ê®Æ¼Æ²Õ
a4 = Split(Mid(t4 & "¡¶Total", 3, 9999), "¡¶")
a5 = Split(Mid(t5 & "¡¶" & tsum, 3, 9999), "¡¶")
' ¦pªG¼Æ²Õ¦³¸ê®Æ
If UBound(a4) > 0 Then
' ±N¼Æ¾Ú¶ñ¥R¨ì«ü©wªº³æ¤¸®æ°Ï°ì
Z.Offset(1, 0).Resize(UBound(a4) + 1, 1) = Application.Transpose(a4)
Z.Offset(1, 1).Resize(UBound(a4) + 1, 1) = Application.Transpose(a5)
End If
End If
Next
End Sub
½Ðª`·N¡A³o¬q¥N½X¬O°ò©ó°²©w³f¬[§Ç¸¹¦C¡]C¦C¡^ªº¦X¨Ö°Ï°ì¥i¥H³q¹L .MergeArea.Count ¥¿½TÀò±o¡C¥t¥~¡A³o¬q¥N½X¨Ï¥Î¤F UCase ¨ç¼Æ¨Ó¶i¦æ¤£°Ï¤À¤j¤p¼gªº¤ñ¸û¡C¦pªG±zªº³f¬[§Ç¸¹°Ï¤À¤j¤p¼g¡A«h¤£À³¨Ï¥Î UCase ¨ç¼Æ¡C |
|