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

[µo°Ý] VBA¤U©Ô¦¡¿ï³æ(¤w¸Ñ¨M)

¦^´_ 9# Hsieh

§Ú·QÄ~Äò©µÄò¤W¦¸ª©¥D»¡ªº¸Ñ¨M¿ìªk
¤£¹L­n¥ýÁÂÁª©¥D, §Ú²×©óª¾¹D"¦WºÙºÞ²z"ªº¥\¥Î(2010)

¥t¤@­Ó¤pºÃ°Ý¦b©ó, §Ú¬O§_¥i¥Hª½±µ¦bVBAªº¼Ò²Õ¸Ìª½±µ¤Þ¥Î³o¨Ç³]©w©O?
¦pªG­n¤Þ¥Î³o¨Ç³]©w, À³¸Ó­n¥Î¤°»ò¤è¦¡¥h°µ¤Þ¥Î


§Ú¦³¸Õ¹L»s§@¤F¤@­Ó¦W¬°Sales
Sales=INDEX(«È¤á¸ê®ÆºÞ²z!$A$2:$D$1000, MATCH(±M®×¬ö¿ý!$C$2:$C$1000, «È¤á¸ê®ÆºÞ²z!$A$2:$A$1000,0),4)

µM«á§Q¥Î¿ý»s¥¨¶°ªº¤è¦¡°O¿ý¿ý»s,
¤§©Ò¥H¤£Ä@·N, ª½±µ¦bÀx¦s®æª½±µ¤Þ¥Î, ¦p¤U¹Ï:

¬O¦]¬°¾ã­ÓÀÉ®×·|Åܫܤj, ¤]¤£¬üÆ[

¿ý¦nªº¾´®×ªø³o¼Ë
Sub ¥¨¶°1()
'
' ¥¨¶°1 ¥¨¶°
'
    Range("D2").Select
    ActiveCell.FormulaR1C1 = "=Sales"
    Range("D3").Select
End Sub

µM«á§Ú§â¥¦§ï¨ì§Úªº¼Ò²Õ¸Ì
Sub ±M®×¬ö¿ý() 'Pro_Statu

Dim NewPro As Range
Dim PN As Range
Dim Cus As Range
Dim Sales_P As Range
Dim EnCus As Range

Sales_P.FormulaR1C1 = "=Sales"

   With Worksheets("±M®×¬ö¿ý")
    Set PN = .Columns(2).Cells.Find(Pro_Statu.Text_PN.Value, LookIn:=xlValues, Lookat:=xlWhole)
    Set Cus = .Columns(3).Cells.Find(Pro_Statu.Combo_Cus.Value, LookIn:=xlValues, Lookat:=xlWhole)
    Set EnCus = .Columns(12).Cells.Find(Pro_Statu.Text_EnCus.Value, LookIn:=xlValues, Lookat:=xlWhole)
   
   
    If Not PN Is Nothing And Not Cus Is Nothing And Not EnCus Is Nothing Then
   
     MsgBox "¸Ó«È¤á¤w¶}¥ß¦¹®×!  ¦p±ý­×§ï¡A½Ð¿ï¾Ü¬ö¿ýºûÅ@¡AÁÂÁ¡D", vbOKOnly + vbExclamation
            Pro_Statu.Combo_Cus.SetFocus
            Exit Sub
     Else
     
      Set NewPro = .Range("a65536").End(xlUp).Offset(0, 0)
        NewPro.Offset(1, 0) = "Going"
        NewPro.Offset(1, 1) = Pro_Statu.Text_PN
        NewPro.Offset(1, 2) = Pro_Statu.Combo_Cus
       NewPro.Offset(1, 3) = Sales_P
'        NewPro.Offset(1, 4) = Qprice
'        NewPro.Offset(1, 5) = Sprice
        NewPro.Offset(1, 6) = Date
        NewPro.Offset(1, 7) = Date
        NewPro.Offset(1, 8) = Pro_Statu.Text_Model
        NewPro.Offset(1, 9) = Pro_Statu.Combo_App
        NewPro.Offset(1, 10) = Pro_Statu.Text_Qty
        NewPro.Offset(1, 11) = Pro_Statu.Text_EnCus
        NewPro.Offset(1, 12) = Pro_Statu.Combo_Cntry
        NewPro.Offset(1, 13) = Pro_Statu.Text_Cap
        NewPro.Offset(1, 14) = Pro_Statu.Text_Rev
        NewPro.Offset(1, 15) = Pro_Statu.Text_Com
     
    End If

    End With

¤£¹L·|¤@ª½¶]¥X¿ù»~°T®§:


¦A³Â·Ð¤j¤j, 3Q

TOP

°ÊºA©w¸q½d³òªº¦WºÙ¡A³Ì¤jªº¦n³B´N¦b©ó¥i¥H¦]À³¸ê®Æ¶q¦¨ªø
½Ðª`·N¹ÏÀɤ¤©w¸q¦WºÙªº¤½¦¡
©w¸q¦n¦WºÙ«á¡A¦bVBA¥u»Ý¤Þ¥Î¸Ó¦WºÙ´N¯à«ü©w¨ì¸Ó½d³ò
RowSourceÄÝ©Ê¥²¶·¦bÄÝ©Êªí¤º³]©w
LISTÄÝ©Ê¥i©óªí³æªì©l¤Æªº¦P®É¡A±N¤U©Ô²M³æªºLISTÄݩʳ]¬°¸Ó¦WºÙ´N¯à¨Ï¥Î
  1. Private Sub UserForm_Initialize()
  2. ComboBox1.List = [x].Value
  3. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 12# Hsieh

¤F¸Ñ
¤£¹L¦pªG¬O¨ä¥L¥Îªk©O
¦p:
Sales=INDEX(«È¤á¸ê®ÆºÞ²z!$A$2:$D$1000, MATCH(±M®×¬ö¿ý!$C$2:$C$1000, «È¤á¸ê®ÆºÞ²z!$A$2:$A$1000,0),4)
§Ú³]©w¤F·í§Ú¿ï¾Ü¤F«È¤á³o­Ó¿ï¶µ, ®ÇÃ䪺·~°ÈÄæ¦ì·|¦Û°Ê§ä´M«e¤@¤@­Óªí®æªº¤º®e, ¨Ã±N¨ä¬Û¹ïÀ³ªº¸ê®Æ¶ñ¤J¦¹ªí®æ¤¤, ¸Ô²Ó¦p¤W¤@­Ó¦^ÂÐ

¥u¬O§Ú¤£ºÞ¦p¦ó¤Þ¥Î
¦p±NSales.Value
³£¬O¤£¦æªº

¤£¹L­è­è¤j¤j¦³´£¨ìrowsourceªºÄÝ©Ê ¥u¯à¦b¸ÓÄݩʤºÅÜ°Ê
©Ò¥H§Ú¤~¦³¦¹¤@°Ý
¦pªG§Ú¦b°ÊºAªí®æ¤º³]©w¤F¨ä¥Lªº¤½¦¡
¨Ì·Ó¤j¤jªºÁ¿ªkÀ³¸Ó¬O¥i¥H³Q¤Þ¥Î¦bVBA¸Ì
¦ý¬O¨C¦¸ªº¿ù»~´N¬O: ¥¼©w¸qÅܼƦWºÙ¤§Ãþªº
Åý§Ú¦³ÂI§xÂZ^^"

¯u¬O¤£¦n·N«ä, ¤£¹L§A­è­è»¡ªº¤èªk
¬O¨S°ÝÃDªº^^ §Ú¤]°O¤U¨Ó°Õ!!
¦A³Â·Ð¤F, ÁÂÁÂ

TOP

¥»©«³Ì«á¥Ñ Hsieh ©ó 2011-5-19 17:09 ½s¿è

§AªºSales©Ò©w¸q¥X¨Óªº·|¬O¬Æ»ò?
INDEX
·|¶Ç¦^®Ú¾ÚÄæ¦C¸¹½X¯Á¤Þ©Ò¿ï¨ú¤§ªí®æ©Î°}¦C¤¤¤@­Ó¤¸¯Àªº­È¡C
¥L¬O¤@­Ó­È¡A¨Ã¤£¬O¤@­Ó°}¦C©Î¬OÀx¦s®æ°Ñ·Ó
·íµMµLªk·í¦¨LIST
¤£¹LÀ³¥i³]¦¨RowSource
§Aªº°ÝÃD¦ü¥G¤£¬O¦b©ó¦p¦ó³]©w¤U©Ô²M³æ
¦Ó¬OÅܼƵ¹­Èªº°ÝÃD
§Aªº«È¤á¿ï¾Ü«á­n¹ïÀ³Sales
MATCH(±M®×¬ö¿ý!$C$2:$C$1000, «È¤á¸ê®ÆºÞ²z!$A$2:$A$1000,0)³o¬O­n±o¨ì¬Æ»ò¸ê®Æ?
§Ú·Q§AÀ³¸Ó±q©w¸q¦WºÙ¤½¦¡¥hÀˬd
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 14# Hsieh


«¢«¢  ©êºp ©êºp§Ú¤@ª½¨S»¡²M·¡
³o¤£¬O¤U©Ô¦¡¿ï³æ, ¥u¬O¦]¬°¬Ý¨ìª©¤j¥Î¤F³o©Û
¬ðµMµo²{, ¨º­Ó¥\¯à¤]¥i¥H©w¸q§OªºªF¦è
©Ò¥H´N¬ðµo©_·Q, ¨º¦pªG§Ú§â­ì¥ý­n©w¸qªº¤½¦¡¤]¥Î¤@­Ó¦WºÙ¥ý©w¸q
©Ò¥H¤~·|¦³­è­è¨º­Ó¤½¦¡
¦Ó¸Ó¤½¦¡¥D­nªº¥Øªº¬O
¬°¸`¬Ù¿é¤J©Òªá¶Oªº®É¶¡
¦b«e¤@±iªí®æ¤º§Ú¦³«Ø¥ß¤F«È¤áªº°ò¥»¸ê®Æ»P©Ò­t³dªº·~°È
©Ò¥H§Ú·|§Æ±æ¤§«á¦pªG¦³¿ï¾Ü¤F«È¤á,  ¦b¿é¤J·s¶}±M®×ªº¸ê®Æ¦P®É, ´N·|¦Û°Ê§â­t³dªº·~°È¤@¦P±a¤J

¦pªG¥u¬O³æ¯Â©w¸q, µM«áª½±µ®M¦¨¤½¦¡¨Ï¥Î´ú¸Õ«á¬OOKªº
¤£¹L°ÝÃD¬O­n¼g¶iVBA¸Ì­±, ´N¤£¦æ­ù,  §ÚÁÙ¯S§O¥Î¤FFormulaR1C1
ÁÙ¬O¤£¦æ(¤£¹L¥Î¿ý»s¥¨¶°ªº¤è¦¡¬Ý¸ÓÀÉ®×, ¸Ì­±½T¹ê¤]¬O¥ÎformulaR1C1)
©Ò¥H¤£À´¬°Ô£§ï¼g«á, ´N¤£¦æ

¯u¬O¤£¦n·N«ä, §Ú¦AÄ~Äò¬ã¨s¤@¤U

TOP

¥ý¬Ý³o¥y
Sales_P.FormulaR1C1 = "=Sales"
¦b³o¥y¤§«e§A¦³±NSales_Pµ¹­È¶Ü?
FormulaR1C1 ÄݩʬOÀx¦s®æªº¤½¦¡
³oÀx¦s®æÅܼƥ²¶·¥ýSET
Set Sales_P=Àx¦s®æ
Sales_P.FormulaR1C1 = "=Sales"
³o¼Ë¤~·|¦¨¥ß¡A¤£µMSales_P¬ONothing
§Ú²q§A¬O­n§âSales_P«ü©w¦¨¦WºÙSales
¨º»ò´N¥ÎSet Sales_P=[Sales]
³o¯Âºé²q´ú¡A­n¤F¸Ñ§Aªº«ä¸ô¤~¯àµ¹§A¥¿½T¤è¦V
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 16# Hsieh


§A¬O¯«XD
­ì¨Ó¦p¦¹
¹ï!! ¥L´N¬O¤@ª½nothing
3Q 坂¤j
³o¼Ë§Ú©ú¥Õ­ù

TOP

        ÀR«ä¦Û¦b : ¬°¤H³B¥@­n¤p¤ß²Ó¤ß¡A¦ý¤£­n¡u¤p¤ß²´¡v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD