VBA¦p¦ó±N¤£¦P¸ê®Æªº°Ï°ì§ì¥X¤ÀÃþ?
- ©«¤l
- 82
- ¥DÃD
- 7
- ºëµØ
- 0
- ¿n¤À
- 112
- ÂI¦W
- 0
- §@·~¨t²Î
- WIN7
- ³nÅ骩¥»
- WIN7
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-1-3
- ³Ì«áµn¿ý
- 2020-9-21
|
VBA¦p¦ó±N¤£¦P¸ê®Æªº°Ï°ì§ì¥X¤ÀÃþ?
½Ð°Ý¦U¦ìª©¤W¤j®v¡A¤p§Ìªì¾ÇVBA
«ä¦Ò¤@ÓÀÉ®×°ÝÃD¤w¸g³\¤[¡A¤]ª¦¤F«Ü¦h¤å³¹
¹Á¸Õ¥Î°j°é§ì¥X¸ê®Æ...¥¢±Ñ..
¹Á¸Õ¥Î°}¦C§ì¥X¸ê®Æ....¤]¥¢±Ñ... ·Q¤F¦n´X¤Ñ§Ë¤£¥X¨Ó
·Q½Ð°Ýª©¤W¤j¤HÌ
¦pªG§Ú·Qn§ì¨ú¤@¥÷¸ê®Æ ²Ä¤@Ósheet ¬OÁ`ªí(·|ÀHºô¶§ó·s§ì¸ê®Æ)
¦p¦ó¨Ï¥ÎVBA ±N¥L¤ÀÃþÅܦ¨ sheet2 . 3 .4 ªº¤ÀÃþ©O?
§Ú±N§Únªº¸ê®Æ°Ï°ì Åܦ¨¬õ¦âªº¦r¼Ë ¥i¥H½Ð¤H«ü¾É¶Ü?
¥t¥~³Ì«nªº´N¬O ²Ä¤@ÓÁ`ªíªº¸ê®Æ¦C¼Æ ·|ÀHµÛ¤ë¥÷¤£¦P ¦Ó¦³¼Æ¶q¤£¦P
¥t¥~ ¬O¤£¬O¯à¦b §ó²Ó¤À¦¨ sheet 4 ¸ò 5 ªººØÃþ©O??
¥t¥~§Ú¦bVBA½s¿è¾¹¨ºÃ䦳¯d¤U§Úªº·Qªk.....¦U¦ì½Ð¥Î¤OÃ@¥´...§Ú¨ì©³¬Oþ¸ÌªºÆ[©À¤£¹ï??
«ôÁ¦U¦ì¤j®v~ |
|
|
|
|
|
|
- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¦^´_ 1# handsometrowa
¸ê®Æ°Ï°ì Åܦ¨¬õ¦âªº¦r¼Ë ,¿ý»s¥¨¶°¸Õ¸Õ¬Ý- Option Explicit
- Dim Rng As Range, AR()
- Sub Main()
- AR = Array("¨ì´Á¤ë¥÷", "¼i¬ù»ù", "¶R½æÅv", "¦¨¥æ¶q", "¥¼¨R¾P«´¬ù¶q")
- With Sheets("¿ï¾ÜÅvÁ`ªí")
- .[L4:M4] = Array("¦¨¥æ¶q", "¥¼¨R¾P«´¬ù¶q") '"*¦¨¥æ¶q" ,"*¥¼¨R¾P'¸ê®Æ®wÄæ"*" ¶i¶¥¿z¿ï¦³·|¦³¿ù»~
- Set Rng = .Range("B4:Q" & .[B4].End(xlDown).Row) '¸ê®Æ®w
- ¿z¿ïµ{¦¡ "¤ÀÃþ¤@"
- ¿z¿ïµ{¦¡ "½æÅv"
- ¿z¿ïµ{¦¡ "¶RÅv"
- .Activate
- End With
- End Sub
- Private Sub ¿z¿ïµ{¦¡(Sh As String) 'SH°Ñ¼Æ¬°¦r¦ê«¬ºA :¤u§@ªí¦WºÙ
- Dim T As String
- With Sheets(Sh)
- .Cells.Clear 'Àx¦s®æ:²M°£
- .[L1].Value = AR(0) '¶i¶¥¿z¿ï: CriteriaRange,·Ç«hÄæ¦ì¦WºÙ("¨ì´Á¤ë¥÷")
- .[A1:E1].Value = AR '¶i¶¥¿z¿ï: CopyToRange,½Æ»s¨ìÀx¦s®æªºÄæ¦ì¦WºÙ
-
- If Sh = "½æÅv" Or Sh = "¶RÅv" Then
- .[L1].Value = AR(2) '¶i¶¥¿z¿ï: CriteriaRange,·Ç«hÄæ¦ì¦WºÙ("¶R½æÅv")
- .[L2] = IIf(Sh = "¶RÅv", "Call", "Put") '¶i¶¥¿z¿ï:·Ç«hÄæ¦ì ³]¥ß±ø¥ó
- End If
- Rng.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=.[L1:L2], CopyToRange:=.[A1:E1], Unique:=True
- .[L1:L2] = "" 'Unique:=True ¶È¿z¿ï°ß¤@ªº°O¿ý
- If Sh <> "½æÅv" And Sh <> "¶RÅv" Then
- .Rows(2).Delete '¸ê®Æ®w²Ä2¦C¬° (¶g§O) ¤£»Ýn§R±¼
- Else
- ¤ë¥÷«´¬ù¿z¿ïµ{¦¡ Sh
- End If
- End With
- End Sub
- Private Sub ¤ë¥÷«´¬ù¿z¿ïµ{¦¡(Sh As String)
- Dim R As Range
- On Error GoTo ER: 'µ{¦¡¿ù»~³B¸Ì:¤ë¥÷«´¬ù¶RÅvªº¤u§@ªí,¦p¤£¦s¦b·|¦³¿ù»~.
- With Sheets(Sh)
- .Range("A:A").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=.Cells(1, .Columns.Count), Unique:=True
- '¿z¿ï [¨ì´Á¤ë¥÷]¦b¤u§@ªí³Ì¥kºÝªºÄæ¦ì
- For Each R In .Range(.Cells(2, .Columns.Count), .Cells(2, .Columns.Count).End(xlDown)) '³Ì¥kºÝªºÄæ¦ìªº[¨ì´Á¤ë¥÷]
- .Range("A1").AutoFilter Field:=1, Criteria1:=R '¦Û°Ê¿z¿ï: AÄæ ·Ç«h= [¨ì´Á¤ë¥÷]
- .Range("A:E").Copy Sheets(R & Sh).[A1] '¤£²Å¦X·Ç«hªº¸ê®Æ·|ÁôÂñ¼
- Next
- End With
- Exit Sub 'Â÷¶}³oµ{§Ç
- ER:
- If Err.Number = 9 Then '¤ë¥÷«´¬ù¶RÅvªº¤u§@ªí
- Sheets.Add Sheets(Sheets.Count) '·s¼W¤u§@ªí
- ActiveSheet.Name = R & Sh '¤u§@ªí:©R¦W
- Resume '¦^¨ìµ{¦¡¿ù»~ÂI
- End If
- MsgBox Err.Description & Err.Number '§iª¾:¤£¬O¤u§@ªí¤£¦s¦b·|¦³¿ù»~.
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤l
- 82
- ¥DÃD
- 7
- ºëµØ
- 0
- ¿n¤À
- 112
- ÂI¦W
- 0
- §@·~¨t²Î
- WIN7
- ³nÅ骩¥»
- WIN7
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-1-3
- ³Ì«áµn¿ý
- 2020-9-21
|
²`²`ªº·PÁª©¥D¡A»¡¯uªº§Ú¬Ý¨ìªº®ÉÔ©ü¤F....
§Ú¸£¤¤ªº·Qªk«ç»ò¼g¥X¨Ó³o»ò½ÆÂø
§Úªº¥\¤O¯uªºÂ÷³oÓ¶¥¬q¦n»·¦n»·...
¥i§_½Ðª©¥D¸ò§Ú¸ÑÄÀ¤@¤U ¤jP¤Wªº¬yµ{
±z¬O«ç»òºc«ä ¤S«ç»ò³B²z³o¨Ç°ÝÃDªº¥ý¨Ó«á¨ìªº@@? |
|
|
|
|
|
|
- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¦^´_ 3# handsometrowa
¤£n³à®ð,§Ú¦³³o¯à¤O¬°§A¸Ñµª,¬O¶O¤F«Ü¦h®É¶¡©Ò¿i½m¥X¨Óªº.
¦³°ÝÃDÅwªï´£°Ý,¦h¬Ý,¦h½m²ß½d¨Ò,·|¶i¨Bªº
Sub Main()
«Ø¥ß¸ê®Æ®w½d³ò
Sub ¿z¿ïµ{¦¡(Sh As String)
¨Ì¶Ç°eªº°Ñ¼ÆSh(¤u§@ªí¦WºÙ)«ü©w¨ì¤u§@ªíª«¥ó: With Sheets(Sh)
×q¶i¶¥¿z¿ï, CriteriaRange[¿z¿ï·Ç«h],Äæ¦ì¦WºÙ( "¨ì´Á¤ë¥÷","¶R½æÅv" ),
[¿z¿ï·Ç«h],Äæ¦ì ³]¥ß±ø¥ó .[L2] = IIf(Sh = "¶RÅv", "Call", "Put")
Sub ¤ë¥÷«´¬ù¿z¿ïµ{¦¡(Sh As String)
¨Ì·ÓSh="½æÅv"©Î¬OSh="¶RÅv",·s¼W¦P¤@¤ë¥÷ªº«´¬ùªº¤u§@ªí |
|
|
|
|
|
|
- ©«¤l
- 82
- ¥DÃD
- 7
- ºëµØ
- 0
- ¿n¤À
- 112
- ÂI¦W
- 0
- §@·~¨t²Î
- WIN7
- ³nÅ骩¥»
- WIN7
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-1-3
- ³Ì«áµn¿ý
- 2020-9-21
|
¦^´_ 4# GBKEE
¦A¦¸«ôÁÂ!!
±z¯uªº¬OÀ°¤F«Ü¤jªº¦£¡A®³¨ì³o¥÷µ{¦¡½Xªº®ÉÔ¡A¤º¤ß¬O¤S·P°Ê¡A¤S²Û·\..
§Æ±æ¦³´Â¤@¤é¦ÂI§¹¦¨§ÚªºªF¦è ¥i¥HÀ°¦£§ó¦h¤H
·PÁª©¥D~ |
|
|
|
|
|
|
- ©«¤l
- 82
- ¥DÃD
- 7
- ºëµØ
- 0
- ¿n¤À
- 112
- ÂI¦W
- 0
- §@·~¨t²Î
- WIN7
- ³nÅ骩¥»
- WIN7
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-1-3
- ³Ì«áµn¿ý
- 2020-9-21
|
Dear ª©¤j
§Ú³Ìªñ¦b©é©Rªº²Îp¸ê®Æªü §Ú¹J¨ìÃøÃD¤F ¥i¤£¥i¥H½Ð°Ý±z(¦]¬°§ÚÁÙ¤£°÷Åv µoµu°T)
±z±Ð¾É§Úªºµ{¦¡½X·í¤¤
Sub Main()
AR = Array("¨ì´Á¤ë¥÷", "¼i¬ù»ù", "¶R½æÅv", "¦¨¥æ¶q", "¥¼¨R¾P«´¬ù¶q")§ÚÀ´
With Sheets("¿ï¾ÜÅvÁ`ªí")§ÚÀ´
.[L4:M4] = Array("¦¨¥æ¶q", "¥¼¨R¾P«´¬ù¶q") ¦³ÂI¤£À´¡A³o¥y¸Üªº·N«ä¬O§â°}¦CÅܼƤ¤ªº³o¨âÓÅܼƽáȵ¹ [L4:M4] ? ¤£¬OÀ³¸Ó¬Û¤Ï?? '"*¦¨¥æ¶q" ,"*¥¼¨R¾P'¸ê®Æ®wÄæ"*" ¶i¶¥¿z¿ï¦³·|¦³¿ù»~
Set Rng = .Range("B4" & .[B4].End(xlDown).Row) '¸ê®Æ®w ³oÓ¸ê®Æ®w½d³ò©w¸q§ÚÀ´
¿z¿ïµ{¦¡ "¤ÀÃþ¤@" ¨º³oÓ ¿z¿ïµ{¦¡ ¥H¤U³o¤TÓ ¤ÀÃþ¤@ ½æÅv ¶RÅv ?? ³o¬O¤°»ò«ü¥O call?©I¥s? §Ú¬Ý¥L¤£¬Oª`¸Ñ À³¸Ó¨Æ·|°õ¦æªºµ{¦¡§a?
¿z¿ïµ{¦¡ "½æÅv"
¿z¿ïµ{¦¡ "¶RÅv" |
|
|
|
|
|
|
- ©«¤l
- 82
- ¥DÃD
- 7
- ºëµØ
- 0
- ¿n¤À
- 112
- ÂI¦W
- 0
- §@·~¨t²Î
- WIN7
- ³nÅ骩¥»
- WIN7
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-1-3
- ³Ì«áµn¿ý
- 2020-9-21
|
·PÁÂGBKEE ~§ÚÀ´¤F ¦ý¬O¥i§_¦A´£°Ý¤@Ó°ÝÃD
³oÓArray ("¦¨¥æ¶q", "¥¼¨R¾P«´¬ù¶q") ¸ò¤@¶}©l³]©wªº¨ºÓAR = Array("¨ì´Á¤ë¥÷", "¼i¬ù»ù", "¶R½æÅv", "¦¨¥æ¶q", "¥¼¨R¾P«´¬ù¶q") ¦³ÃöÁp¶Ü? §Ú·Q§Ú¬O³oÓ¦a¤è¥X°ÝÃD ¨Ì·Ó±zªº·Qªk¡A
.[L4] ="¦¨¥æ¶q"
.[M4]= "¥¼¨R¾P«´¬ù¶q") ¥u¬O§âRange("L4") ½áÈÅܦ¨ ¤å¦rÀÉ ¦Ó¤w
©Ò¥H¸ò¤@¶}©l³¯z°}¦CÅܼƨº¤Óªº¦WºÙ¦³Ãö«Y¶Ü?
.[L4:M4] = Array("¦¨¥æ¶q", "¥¼¨R¾P«´¬ù¶q")
µ¥¦P
.[L4] ="¦¨¥æ¶q"
.[M4]= "¥¼¨R¾P«´¬ù¶q") |
|
|
|
|
|
|
- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¥»©«³Ì«á¥Ñ GBKEE ©ó 2013-6-7 15:56 ½s¿è
¦^´_ 8# handsometrowa
¸ò¤@¶}©l³¯z°}¦CÅܼƨº¤Óªº¦WºÙ¨S¦³Ãö«Yªº*¦¨¥æ¶q *¥¼¨R¾P -> ¸ê®Æ®wÄæ¦ì¦WºÙ¤£¥i¥H¦³ * ,¥h±¼*ªº§@¥Î¦Ó¤w. 1#»¡:§Ú·Qn§ì¨ú¤@¥÷¸ê®Æ ²Ä¤@Ósheet ¬OÁ`ªí(·|ÀHºô¶§ó·s§ì¸ê®Æ)
¦p¦ó¨Ï¥ÎVBA ±N¥L¤ÀÃþÅܦ¨ sheet2 . 3 .4 ªº¤ÀÃþ©O?
§Ú¥Î¤F [¶i¶¥¿z¿ï]ªº¤èªk- AdvancedFilter ¤èªk [¶i¶¥¿z¿ï]
- ½Ð°Ñ¾\®M¥Î¦Ü½d¨Ò¯S©w°ò©ó·Ç«h½d³ò±q¸ê®Æ²M³æ¤¤¿z¿ï©Î½Æ»s¸ê®Æ¡C¦pªGªì©l¿ï©w¬°³æÓÀx¦s®æ¡A«h¨Ï¥ÎÀx¦s®æ¥Ø«eªº°Ï°ìx¬°Variant¡C
- expression.AdvancedFilter(Action, CriteriaRange, CopyToRange, Unique)
- expression ¥²¿ï¡C¸Ó¹Bºâ¦¡·|¶Ç¦^ [®M¥Î©ó] ²M³æ¤¤ªº¨ä¤¤¤@Óª«¥ó¡C
- Action ¥²¿ïªº XlFilterAction ¸ê®ÆÃþ«¬¡C
- XlFilterAction ¥i¥H¬O³o¨Ç XlFilterAction ±`¼Æ¤§¤@¡CxlFilterCopy ,xlFilterInPlace.
- CriteriaRange ¿ï¾Ü©Êªº Variant¡C·Ç«h½d³ò¡C¦pªG¬Ù²¤¦¹¤Þ¼Æ«hµL·Ç«h¡C
- CopyToRange ¿ï¾Ü©Êªº Variant¡C¦pªG Action ¬° xlFilterCopy¡A¦¹¤Þ¼Æ«ü©w³Q½Æ»s¦Cªº¥Ø¼Ð½d³ò¡C§_«h©¿²¤¦¹¤Þ¼Æ¡C
- Unique ¿ï¾Ü©Êªº Variant¡CY¬° True¡A«h¶È¿z¿ï°ß¤@ªº°O¿ý¡FY¬° False¡A«h¿z¿ï¥X©Ò¦³²Å¦X·Ç«hªº°O¿ý¡C¹w³]Ȭ° False¡C
½Æ»s¥N½X [¿ï¾ÜÅvÁ`ªí] ¬°¸ê®Æ®w¥H¤U¬°¥¦ªºÄæ¦ì¦WºÙ
«´¬ù ¨ì´Á¤ë¥÷ ¼i¬ù»ù ¶R½æÅv ¶}½L»ù ³Ì°ª»ù ³Ì§C»ù ³Ì«á µ²ºâ»ù º¦¶^»ù º¦¶^% *¦¨¥æ¶q *¥¼¨R¾P ³Ì«á³Ì¨Î¶R»ù ³Ì«á³Ì¨Î½æ»ù ¾ú¥v³Ì°ª»ù ¾ú¥v³Ì§C»ù
[¿ï¾ÜÅvÁ`ªí]¤¤«ü©wn¿z¿ïªºÄæ¦ì,¥Î AR = Array("¨ì´Á¤ë¥÷", "¼i¬ù»ù", "¶R½æÅv", "¦¨¥æ¶q", "¥¼¨R¾P«´¬ù¶q") ,¤@¦¸ªº½Æ»s¨ì
sheet2 . 3 .4 ¤¤,«K©óAdvancedFilterªº¿z¿ï. |
|
|
|
|
|
|
- ©«¤l
- 82
- ¥DÃD
- 7
- ºëµØ
- 0
- ¿n¤À
- 112
- ÂI¦W
- 0
- §@·~¨t²Î
- WIN7
- ³nÅ骩¥»
- WIN7
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-1-3
- ³Ì«áµn¿ý
- 2020-9-21
|
¦^´_ 9# GBKEE
Dear GBKEE
·PÁ±z¤§«eµ¹ªºµ{¦¡½X¡A°µ¥X¨ÓªºªF¦è²Å¦X§ÚnªºªF¦è¡A¦ý¬O«áÄòÁÙ¥i¯àn²K¥[¦Û°Êpºâ
§Ú¤µ¤Ñ§â¾ãÓµ{¦¡¤À¶}¬Ý¤F¤@¤U¡A¦b¦Û°Ê¿z¿ïªº¦a¤è §Ú¯uªº§¹¥þ¤£¤F¸Ñ¡A§Ú¤µ¤Ñ¥hEXCEL ¬Ý¤F»¡©ú
¦b©w¸q¤@Ó½d³ò¦WºÙ¤]¦n¡A¿ï¨ú¤@Ó½d³ò¤]¦n¡A¦b¨Ï¥Î¶i¶¥¿z¿ïªº®ÉÔ¡Aµ¹¤©·Ç«h¨Ã¥B½Æ»s¨ì¬YÓ¦a¤èªº®ÉÔ..
¥L³£¥u¯à¦b¦P¤@Ó¤u§@ªí¤W±¨Ï¥Î¿z¿ï«áªº·Ç«h±ø¥ó½Æ»s¨Ã¥B¶K¤W¡A¤£¯à¸ó¤u§@ªí¶K¤Wªü@@"
¥i¬O§Ú¤µ¤Ñ¥Î¤F±ø¦C¦¡°»¿ù¶]µ{¦¡¡A¥i¬O±z¤@¶}©l¸ê®Æ®w©w¸q§¹¤§«á¡A´N¥i¥H§â¿z¿ï¹L«áªº¸ê®Æ¶K¨ì"¶RÅv"©Î¬O"½æÅv" ªº¤u§@ªí¸Ì±
µM«á¦A¶i¦æ¶i¤@¨Bªº¿z¿ï¡AµM«á¦A¶K¤W¨ì·s¼W¥[ªº¦WºÙ¤u§@ªí¤W
³o¯uªº¦Ê«ä¤£±o¨ä¸Ñªü!! EXCEL¤£¯à¶i¶¥¿z¿ï«á¶K¨ì§Oªº¤u§@ªí¡A¥i¬OVBA¥i¥H?
PS:¨ä¹ê±zÀ°§Ú³]pªºµ{¦¡ "¶RÅv"¸ò"½æÅv" ¥i¥H»Ýn¥i¥H¤£n¡A"¤ÀÃþ¤@"¨ºÓ¬O·íªì¸ÑÄÀ¥Î¨ä¹ê¤£¥Î¨ºÓ¤u§@ªí¤F¡Aµù°Oµ{¦¡½X¤§«á¥i¥HÄ~Äò¹B¦æ¡A·PÁÂ^^ |
|
|
|
|
|
|