ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[¤À¨É] Àu¤Æ¥¨¤jªºVBA

¥»©«³Ì«á¥Ñ GBKEE ©ó 2011-7-21 11:34 ½s¿è

¦^´_ 5# play9091
¨S¦³¶}ªºÀɮ׳£¥i¥H§ì¨ì¸ê®Æ  ¤£¥i¥Hªº¤W¤@¦^ÂЦ³µ§»~  ¥H§ó¥¿ ,¥i¥Î¶×¤J¥~³¡¸ê®ÆŪ¨ú.

Set KPI = Workbooks.Open(KPI) , ±NÅܼÆKPI«ü©w¬°  Workbooks.Open(KPI) ³oª«¥ó.
KPI.Close     ³o¼Ë´NÃö±¼

À³¸Ó¬O³o¼Ë   
Set GGG = Selection       ±NÅÜ¼Æ GGG«ü©w¬° Rangeª«¥ó, Selection¬ORangeª«¥ó.

TOP

¸Õ¬Ý¬Ý   Workbooks("¸ôÍߪ©.XLS")   ³oÀɮפ£»Ý¬O¤w¶}±Òªº.\
YES¡I¡I¡I¯uªº·d©w¤F¡Aª©¤j¯u±j¡A³o©Û¥ý¾Ç°_¨Ó¡K¡K¥Î³o­Ó¤èªk¬O¤£¬O³s¨S¦³¶}ªºÀɮ׳£¥i¥H§ì¨ì¸ê®Æ¡H¡H

§Ú±N§Aªºµ{¦¡½X²¤Æ¬O°t¦X§Aªºµ{§Ç»Ý¨D
1¼Óªºµ{¦¡½X¦³
Workbooks(Clu).Close SaveChanges:=False     '³o¤£¬O¤§«e ±NÀɮ׶}±Ò «á§@Ãö³¬ªº°Ê§@¶Ü?


¥¦ªº½T¬OÃö³¬¤§«e¶}±ÒªºÀɮרS¦³¿ù¡A¦ý¬OWorkbooks(Clu)¸Ì­±ªº¡uClu¡v¥²¶·¬Oºë½TªºÀɦW¡A­n¤£µM·|Ãö¤£±¼¡K¡K

¥t¥~¡G§Ú·Q­n¥u½Æ»s¤@­Ó¡u½d³ò¡vªº¡u­È¡v¡A§ÚÁÙ·Q¤£¨ì«ç»ò°µ¡A¦]¬°¤@¦¸­n½Æ»sªº¸ê®Æ¤Ó¦h¤F(¦Ê¸U¯Åªº)¡I½Æ»sªº®É­Ô­nµ¥«Ü¤[¡K¡K¦³¨S¦³¥i¥H¡u¥u½Æ»s­È¡vªº¤èªk¡I
§Ú·Q¤F¤@¨Ç¡A¦ý³£¨S¦³¦¨¥\¡K¡K½Ð¥ý¶i­Ì«ü¾É¤@¤U¦p¦ó¥u¨ú­È¡I¡I¡I
  1.     Sheets("C" I).Select
  2.     Range("A11").Select
  3.     Range(Selection, Selection.End(xlToRight)).Select
  4.     Range(Selection, Selection.End(xlDown)).Select
  5.     set GGG.value = selection.value   '¥X¿ù
½Æ»s¥N½X
ªì¾ÇVBA¥E¨ìtwbts

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2011-7-21 11:33 ½s¿è

¦^´_ 3# play9091
Workbooks("¸ôÍߪ©").Sheets("¤u§@ªí3").Range("D" & I).Value  '¡ö³o¸Ì¥X¿ù¡I¡I¡I
¸Õ¬Ý¬Ý   Workbooks("¸ôÍߪ©.XLS")   ³oÀÉ®×¥²»Ý¬O¤w¶}±Òªº.
§Ú¥u¶·­nBOOKªºÀɦW¦Ó¤w¡I¡I¡IÀ³¸Ó¬O¥Î¤£¤W¡I¦Ó¥B§Ú¤U­±¥²¶·­n¥Î¨ìBOOKªº¦W¦r¡Aºë½T¤@ÂIÀ³¸Ó·|¤ñ¸û¦n¡I
§Ú±N§Aªºµ{¦¡½X²¤Æ¬O°t¦X§Aªºµ{§Ç»Ý¨D
1¼Óªºµ{¦¡½X¦³
Workbooks(Clu).Close SaveChanges:=False     '³o¤£¬O¤§«e ±NÀɮ׶}±Ò «á§@Ãö³¬ªº°Ê§@¶Ü?
Workbooks(Pag).Close SaveChanges:=False

TOP

¥»©«³Ì«á¥Ñ play9091 ©ó 2011-7-21 09:53 ½s¿è

§Ú§â¥¦­×§ï¦¨¤U­±ªº¼Ë¤l¡A¤£­n¥Î¡uinputbox¡vª½±µ¦bsheet¸Ì­±§â¸ôÍߥý¼g¦n¡A³o¼Ë¤l´N¤£¥Îµ¥¡uinputbox¡v¸õ¥X¨Ó¡C
¦ý¬O¥¦½T¥X²{¤F¡u¶W¥X¯Á¤Þ½d³ò¡v¥N¸¹9ªº¿ù»~¡A§Ú¥u­n§âBOOKªºª«¥ó®³±¼´N¥¿±`¤F¡A¦ý§Ú¥²¶·­n«ü©wBOOK¤ñ¸û¤£·|¥X¿ù¡C§Ú¸Õ¤F¦n¦h¤èªk¡A¥¦´N¬O¤£µ¹°Ê§@¡A¤£ª¾¹D¬O¤£¬O§Úº|¤F¤°»ò¦a¤è¡A·Ð½Ð¥ý¶i«ü¾É¤@¤U¡I¡I¡I
  1. Sub name_test()
  2.     Application.ScreenUpdating = False
  3.     Application.DisplayAlerts = False
  4.     T = Time
  5.     For I = 4 To 10
  6. '¥s¥XKPI³ø§i
  7.     KPI = Workbooks("¸ôÍߪ©").Sheets("¤u§@ªí3").Range("D" & I).Value  '¡ö³o¸Ì¥X¿ù¡I¡I¡I
  8.     Workbooks.Open (KPI)
  9.     Set KPI = Nothing
  10.     KPI = ActiveWorkbook.Name
½Æ»s¥N½X
¥t¥~¡AªO¥D¦^½ÆªºÂ²¤Æ¤è¦¡
  1. Set KPI = Workbooks.Open(KPI)
½Æ»s¥N½X
³o¨ú¥X¨Óªº¬O¥þ³¡Ãö©óBOOKªº¤º®e¡A§Ú¥u¶·­nBOOKªºÀɦW¦Ó¤w¡I¡I¡IÀ³¸Ó¬O¥Î¤£¤W¡I¦Ó¥B§Ú¤U­±¥²¶·­n¥Î¨ìBOOKªº¦W¦r¡Aºë½T¤@ÂIÀ³¸Ó·|¤ñ¸û¦n¡I
ªì¾ÇVBA¥E¨ìtwbts

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2011-7-21 08:31 ½s¿è

¦^´_ 1# play9091
  1. KPI = InputBox("C#KPI³ø§i¸ôÍß(¶¶§Ç±qC4¡ãC9¡A³Ì«á¤~¬OC1)")
  2.     Workbooks.Open (KPI)
  3.     Set KPI = Nothing
  4.     KPI = ActiveWorkbook.Name
½Æ»s¥N½X
KPI = InputBox("C#KPI³ø§i¸ôÍß(¶¶§Ç±qC4¡ãC9¡A³Ì«á¤~¬OC1)")
    Set KPI = Workbooks.Open(KPI)
  1.     Workbooks(Clu).Sheets("sheet1").Copy After:=Workbooks(KPI).Sheets("M2000 BSC KPI Report (2)")
½Æ»s¥N½X
Clu.Sheets("sheet1").Copy After:=KP.Sheets("M2000 BSC KPI Report (2)")
  1. '¶}©l¥X³ø§i
  2. Sheets("paging").Select
  3.     Range("A11").Select
  4.     Range(Selection, Selection.End(xlToRight)).Select
  5.     Range(Selection, Selection.End(xlDown)).Select
  6.     Selection.Copy
  7.     If I <> 10 Then
  8.     Sheets("M2000 MSC Paging").Select
  9.     ElseIf I = 10 Then
  10.     Sheets("sheet5").Select
  11.     End If
  12.     Range("A2").Select
  13.     Range(Selection, Selection.End(xlToRight)).Select
  14.     Range(Selection, Selection.End(xlDown)).Select
  15.     ActiveSheet.Paste
½Æ»s¥N½X
'¶}©l¥X³ø§i
    If I <> 10 Then
    Sheets("M2000 MSC Paging").Select
    ElseIf I = 10 Then
    Sheets("sheet5").Select
    End If
Sheets("paging").Range("A11").CurrentRegion.Copy  ActiveSheet.Range("A2")
CurrentRegion  :±N¿ï¾Ü½d³ò¦Û°Ê©µ¦ù->     Range(Selection, Selection.End(xlToRight)).Select
                                                                                Range(Selection, Selection.End(xlDown)).Select
¨ä¾lÃþ¦ü¥i¦Û¦æ­×§ï

TOP

        ÀR«ä¦Û¦b : ¥@¤W¦³¨â¥ó¨Æ¤£¯àµ¥¡G¤@¡B§µ¶¶ ¤G¡B¦æµ½¡C
ªð¦^¦Cªí ¤W¤@¥DÃD