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

[µo°Ý] Àɮ׶}±Ò°ÝÃD¡A¤ÎVBAÆ[©À°ÝÃD

[µo°Ý] Àɮ׶}±Ò°ÝÃD¡A¤ÎVBAÆ[©À°ÝÃD

¦U¦ì¤j¤j ±ß¤W¦n~
¦³­Ó´X­Ó°ÝÃD·Q¦V¦U¦ì¦Ñ®v­Ìµo°Ý¡A
1.¹³¶}±ÒÀɮ׮ɤp©f³q±`³£¨Ï¥Î Workbooks.Open "C:\TEST\AA.xls"
³oºØ¤è¦¡¶}±Ò¡A·Q½Ð±Ð¦p­n¶}±ÒÀɮצb¦P­Ó¥Ø¿ý¤U®É¡A¬O§_¥i¤£«ü©w¸ô®|¤è¦¡¦Ó¶}±ÒÀÉ®×

¦]­è±µÄ²VBA¹ïEXCELªºÀ³¥Î±q«e³£¥u°±¯d¦b²[¼Æ¨Ï¥Î¡A±`±`³£¦b°µ³øªí¤ÀªR«á¨Ó·|¨Ï¥Î
¿ý»s¥¨¶°¤è¦¡¥h³B²z¤@¨ÇÁc½Æªº°Ê§@¡A«á¶}©l±µÄ²VBAÀ³¥Î¤è¦¡§¹¥þ¤£¬Û¦P¡A²{¦b¤]ÁÙ¬O§V¤O
ªº¥Î¬Ý®Ñ¤Îª¦¤å¤è¦¡¥h¦h¤F¸Ñ¤@¨Ç¡A¦ý¹ï«Ü¦h°Ê§@ÁÙ¬O«Ü¤£¤F¸Ñ¡A¤]·|¦A¦h§V¤O§Æ±æ¯à¥[§Ö¶i¨B
¦³¤@°ÝÃD
2.¹³§Ú¦³¿ý»s¦nªº¥¨¶°¦b SHEET¤¤­Y·Q±Nµ{¦¡½X¥[¤J  CommandButton«ö¤U±Ò°Ê³qª¾³£·|¥X²{
¤è¦¡¤£¥¿½Tªº¿ù»~¡A¦ý¦p¥Îuserform¤è¦¡¦A¥[¤JCommandButton«ö¶s«o¯à°õ¦æ¡Aµ{¦¡½X¤º®e
³£¬Û¦P¹ê¦b¤£¤F¸Ñ¬O¦ó­ì²z·|³o¼Ë?
3.¤§«e¤]¦³µo°Ý´£°Ý¤@¨ÇVBAªºÀ³¥Î¤è¦¡¡A§Ú±N¥¦©M§Ú¿ý»s¦nªº¤º®e©ñ¦b¤@°_®É³£¤£¯à¥¿½T§¹¦¨
°Ê§@¡A·Q½Ð°Ý¿ý»sªº¤º®e©M¦³«Å§iÅܼƤΰʧ@ªºSUB¬O¤£¯à©ñ¦b¦P¤@­ÓCommandButton¤@°_°õ
¦æ³o¼Ë¬O¶Ü? ¦]¬°¦³¤@¨Ç°ÝÃD§Ú¥i¥H¦b¿ý»s¤º®e¤¤§¹¦¨¡A·Q¦b¿ý»s¤º®e¶i¦æ¨ì¬Y¤@³¡¥÷®É¥[¤J°õ
¦æ¥HVBA ¤è¦¡ªºµ{¦¡µM«á¦AÄ~Äò¶i¦æ§Ú¿ý»sªº¤º®e¦ý¦]¤£¼ô±x¨Ï¥Î¤è¦¡¡A³£¤@ª½¤£¯à¦¨¥\¡C

«Ü©êºp¤S¤@¦¸°Ý¤F¤@°ï°ÝÃD¡A¦]²{¦b¤]®³¤£¥X¨ãÅ骺ÀÉ®×¹ê¦b¤]«ÜÃø§Î®e¡A¤£¦X³W©w¤]§Æ±æ¦U¦ì
¦Ñ®v¯àµ¹­ÓÆ[©Àªº«ü¾É¡AÁÂÁ¤j®a
½Ð¦h¦h«ü±Ð

¥»©«³Ì«á¥Ñ luhpro ©ó 2013-8-30 00:22 ½s¿è

ayubbs µoªí©ó 2013-8-29 22:46
1. ¦p­n¶}±ÒÀɮצb¦P­Ó¥Ø¿ý¤U®É¡A¬O§_¥i¤£«ü©w¸ô®|¤è¦¡¦Ó¶}±ÒÀÉ®×

Workbooks.Open ThisWorkbook.Path & "\AA.xls"

2. Sheet »P userform ¤¤ªº CommandButton ª«¥ó³B²z,
µ{¦¡½X¤º®e³£¬Û¦P¹ê¦b¤£¤F¸Ñ¬O¦ó­ì²z·|³o¼Ë?

¦]¬° ¥Îuserform¤è¦¡¦A¥[¤JCommandButton«ö¶s,
°õ¦æ®Éªº«ü¥O¤j³£¦b¸Ó userform ªºµ{§Ç¤º,
¬G¦Ó©¹©¹¤£»Ý«ü©w CommandButton «ö¶sªº¤÷ª«¥ó(userform)´N¥i¥¿±`¨Ï¥Î.

µM¦Ó¬Û¹ï©ó¦b SHEET ¤¤¥[¤Jªº CommandButton ª«¥ó,
ÁöµM¨âªÌ³£¬O CommandButton ª«¥ó,
¦ý«áªÌ¦³¨Ç«ü¥O¬O¨S¦³ªº,
¨Ò¦p : CommandButton1.TabIndex

ÁÙ¦³¦b SHEET ¤¤ªº CommandButton ª«¥ó¦b¤Þ¥Î®É,
¥i¯à±`±`»Ý­n¥Î Sheet("Sheet1").CommandButton1 ªº¤è¦¡¤~¯à¥¿±`¨Ï¥Î
(·í«ü¥O«D¦b¸Óª«¥ó¥»¨­ªº¨Æ¥óµ{§Ç<CommandButton1_Click ¤§Ãþ>¤¤®É, ¨Ò¦p : Worksheet_Change).

3. ¦³¤@¨Ç°ÝÃD§Ú¥i¥H¦b¿ý»s¤º®e¤¤§¹¦¨¡A·Q¦b¿ý»s¤º®e¶i¦æ¨ì¬Y¤@³¡¥÷®É¥[¤J°õ
¦æ¥HVBA ¤è¦¡ªºµ{¦¡µM«á¦AÄ~Äò¶i¦æ§Ú¿ý»sªº¤º®e¦ý¦]¤£¼ô±x¨Ï¥Î¤è¦¡¡A³£¤@ª½¤£¯à¦¨¥\¡C

¤£¯à¥¿½T§¹¦¨°Ê§@¤j³£¬O®M¥Î¿ù»~,
§A­n¥ý½T»{§A·Q°µªº¬O¤°»ò,
µ{¦¡¼g¦n«á¥i¥H¦b°ÝÃDµo¥Í«eªº«ü¥O¦æ,
¥Î·Æ¹«ÂI¤@¤U¨ä¥ªÃ䪺¦Ç¦â°Ï°ì¶}±Ò¤¤Â_¼Ò¦¡.

«ö F5 «öÁä°õ¦æ¨ì¸Ó¦æµ{¦¡·|¼È°±,
¦A§Q¥Î F8 «öÁ䪺³æ¨B¼Ò¦¡,
¥ý½T»{¤U¤@¦æ§Y±N°õ¦æªº«ü¥O¤¤ªº¬ÛÃöÅܼƩΪ«¥ó¬O§_¬°¥¿½T­È.

¨ú­È¥i±N·Æ¹«²¾¨ì·Q°lÂܪºÅܼƩΪ«¥ó¦WºÙ¤W¤£°Ê´X¬í´N·|¨q¥X¨ä²{¦b­È,
©Î¬O¶}±Ò °Ï°ìÅÜ¼Æ µøµ¡½T»{ÅܼƭȬO§_¥¿½T,
¤]¥i©ó §Y®Éµøµ¡¤¤ µ½¥Î ? «ü¥O¨D­È.

¦A©ó §Y®Éµøµ¡¤¤ ¹ê°µ¸Ó¦æ«ü¥O,
¬Ý¬O§_°Ê§@©ÎÅã¥Üªºµ²ªG¥¿±`,
³o¼Ë¤@¨B¤@¨Bªº§ä¥X°ÝÃDÂI.

¥t¥~¦b§Y®Éµøµ¡¤¤¤£¯à¥¿±`°õ¦æ With «ü¥O,
©Ò¥H¥²¶·¥ý±N . ¥N´«¦¨§¹¾ãªºª«¥ó¤Þ¥Î«ü¥O¤~¯à¥¿±`¹B§@,
¨Ò¦p :
With Sheets("Sheet1")
  With .Cells(2, 3)
    With .Font
      .Name = "·s²Ó©úÅé"
      .Bold = True
      .ColorIndex = 1
    End With
  End With
End With

¨ä¤¤ ¦b§Y®Éµøµ¡ ­n¹ê°µ¥X .Name = "·s²Ó©úÅé" ³o¦æ«ü¥Oªºµ²ªG,
´N­n§ï¦¨ Sheets("Sheet1").Cells(2, 3).Font.Name = "·s²Ó©úÅé" ¤~¥i¥H.

ÁÙ¦³­Y«ü¥O¤Óªø¤£¦n°O¾Ð©Î¬O¤£½T©w±µ¤U¨Ó¸Ó¤U­þ­Ó°Ñ¼Æ®É,
¥i¥H¥ý¦b§Y®Éµøµ¡¤W¥Î¥H¤Uªº¤è¦¡¨Ó§ì¥¿½Tªº«ü¥O½X:
range.
sheets.
range.Find(
¥H¤W¬O§Ú³]­p Excel VBA µ{¦¡®É¸I¾À¤FµL¼Æ¦¸,
¤~¸Õ¥X¨Óªº§Þ¥©.

TOP

¦^´_ 2# luhpro

ÁÂÁÂluhpro¤j«ü¾É,¤p©f·|¦A¦h¥Î¤O½m²ß,¤£·Q¦b¹J¨ì§xÃø®É
¥u¦V¤H¨D¸Ñµª¦Ó«o¤@ª½¤£¤F¸Ñ·N¸q,ÁÂÁÂ...¦A¨Ó¦³ºÃ°Ý®É¤]§Æ±æ¦U¦ì
¦Ñ®v¤£§[«ü¾É
½Ð¦h¦h«ü±Ð

TOP

        ÀR«ä¦Û¦b : µoµÊ®ð¬Oµu¼ÈªºµoºÆ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD