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

½Ð±Ð¥Ñ¥¨¶°¿ý¨îªº¤½¦¡¦p¦óÂà´«¬°VBA¤½¦¡,¨Ã¥BÀx¦s®æ¥i¥H¬OÅܼÆ

½Ð±Ð¥Ñ¥¨¶°¿ý¨îªº¤½¦¡¦p¦óÂà´«¬°VBA¤½¦¡,¨Ã¥BÀx¦s®æ¥i¥H¬OÅܼÆ

ActiveCell.FormulaR1C1 = _
        "=IF(AND(RC[-1]=[hub.xls]AA!R2C2,[hub.xls]AA!R2C24>0,[hub.xls]AA!R2C24-SUM(R2C11:RC[5])>0), [hub.xls]AA!R2C9)"
ActiveCell.Offset(1).Select

½Ð±Ð¦U¦ìª©¤j¡A¦p¤W¤½¦¡¬°±q¥¨¶°COPY¨ìVBA¤¤¡A¦ý¬O²{¦b§Ú¦³°ÝÃDµLªk¸Ñ¨M¡A
¦pªG[hub.xls]AA!R2C2¤Î[hub.xls]AA!R2C24¤Î[hub.xls]AA!R2C24¤Î[hub.xls]AA!R2C9³o¥|­Ó¬O¥t¥~¤@­Ó
Àɮפ¤ªºÀx¦s®æ³£¦b¦P¤@¦C¡A²{¦b§Ú»Ý­n±N"¦æ"¬O¥i¥HÅܰʪº¡A¸Ó¦p¦ó­×§ï?

¥t¥~[hub.xls]AA!R2C24-SUM(R2C11:RC[5])>0³o­Ó¸Ì­±ªºSUM(R2C11:RC[5])ªº²Ö¥[À³¸Ó¬O­n¥u²Ö¥[»P[hub.xls]AA!R2C9ªº­È¤@¼Ë¸ÓÀx¦s®æ¹ïÀ³¨ì¦P¤@¦Cªº¼Æ¶qÀx¦s®æ§@²Ö¥[

¥i§_½Ð°ª¤âÀ°¦£¬Ý¤@¤U¸Ó«ç»ò¼gVBA¤ñ¸û¦n

¥»©«³Ì«á¥Ñ luffyzoro ©ó 2011-11-22 02:59 ½s¿è

·q½Ð«üÂI.rar (34.38 KB) ¦^´_ 2# Hsieh

ª©¤j±z¦n
·PÁ±z¼ö¤ß¦^ÂÐ
¤p§Ì¦]¤u§@»Ý­n,¦]¦¹À|¸Õ¼gVBA
¼g¤F¤@°ï¦Û¤v¬Ý¤F³£«Ü½ÆÂøªºµ{¦¡½X,¼g¨ì¥d¦í¤F
Àµ½Ðª©¤j¶}ÄÀ
¸Ó¥Î¤°»ò¼gªk¤~¯à§¹¦¨¤p§Ì·Q­n¹F¦¨ªº§¹¦¨ÀÉ
¨ä¤¤¦³ªþ¤W¤p§Ì¼gªº
Àµ½Ðª©¤j«üÂI

TOP

¦^´_ 2# Hsieh

hubcn = 2
    ActiveCell.FormulaR1C1 = _
        "=IF(AND(RC[-1]=[hub.xls]AA!"R"&hubcn&"C2",[hub.xls]AA!"R"&hubcn&"C24">0,[hub.xls]AA!"R"&hubcn&"C24"-SUM(R2C11:RC[5])>0),[hub.xls]AA!"R"&hubcn&"C9")"

½Ð°Ýª©¤j­Y·Ó±zÁ|¨Ò¬O§_¬O¼g¦¨¦p¤W?³o¦¸§Ú­nÅܰʪº¬Orows
¦ý¬O«o¥X²{»yªk¿ù»~?

½Ð°Ý­þ¸Ì»Ý­n­×¥¿?

·PÁÂ

TOP

¥»©«³Ì«á¥Ñ luffyzoro ©ó 2011-11-23 17:50 ½s¿è

¦^´_ 5# Hsieh


    ¦A¦¸·PÁ¤j¤j¨³³tªº¦^ÂÐ,§Ú¤S¦³·s°ÝÃD¤F

Application.Dialogs(xlDialogOpen).Show
  Dim hubopf As String
  hubopf = ActiveWorkbook.Name¡ö§Úªº¥Î·N¬O­n¨ú±o¥H¹ï¸Ü®Ø³Í±ÒÀɮתº¦WºÙ,¬O§_³o¸Ì¦³°ÝÃD?
  Worksheets("AC-8E").Cells.Select
  Worksheets("AC-8E").Range("A:BY").Sort Key1:=Worksheets("AC-8E").Range("D2"), _
    Order1:=xlAscending, Key2:=Worksheets("AC-8E").Range("I2") _
    , Order2:=xlAscending, Header:=xlYes
  ThisWorkbook.Activate
  Dim calopf As String
  calopf = ThisWorkbook.Name
  ActiveSheet.Cells.Select
  Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Key2:=Range("C2"), _
   Order2:=xlAscending, Key3:=Range("E2"), _
   Order3:=xlAscending, Header:=xlYes
  Cells(ActiveSheet.Rows.Count, 6).End(xlUp).Select
  Selection.Offset(1, 0).Select
  Workbooks(hubopf).Worksheets("AC-8E").Activate¡ö³v¦æ°õ¦æ¨ì³o¸Ì¥X²{¿ù»~"«¬ºA¤£²Å¦X"

½Ð°Ý¬O¤£¬O§Ú¦b«Å§ihubopf³o­ÓÅܼƮɦ³°ÝÃD?

·PÁ¤j¤j

TOP

¦^´_ 7# Hsieh


    ª©¤j¦A¦¸·PÁ±zªº¼ö¤ß

©êºp,§Ú¨S¦³§â°ÝÃD»¡²M·¡
°²³]§Úªº¥¨¶°¬O¼g¦bA.xls , ¥ÎA.xls¶}±ÒB.xls , ·Óª©¤jªº¤è¦¡§Úªºhubopf·|±o¨ì
"D:\C¸ê®Æ§¨\F¸ê®Æ§¨\B.xls"
¹ê»Ú¤W§Ú·Q±o¨ìªº¦r¦ê¥u¦³ "B.xls" ,¦]¬°¨C¦¸¶}ªºÀɦW¥i¯à¤£¤@¼Ë
©Ò¥H§Ú·Q±Nhubopf = "B.xls"
¦p¦¹«áÄòªºWorkbooks("hubopf")À³¸Ó´N·|·ÓµÛ¶}±Ò¤£¦PªºÀÉ®×°µÅÜ°Ê

½Ð°Ý
1.§Ú¸Ó¦p¦ó¨ú±ohubopf = "B.xls"ÀHµÛ¶}±ÒÀɦW¤£¦P¤]¥i¯à¬O"C.xls"
2.«áÄò­n®M¥ÎWorkbooks¬O­n¼gWorkbooks(hubopf)ÁÙ¬O­n¼gWorkbooks("hubopf")?

·PÁÂ

TOP

¦^´_ 9# GBKEE

·PÁÂGBKEEª©¤j
Dim hubopf As String, AR
    hubopf = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
    If hubopf = "False" Then MsgBox "½Ð¿ï¨úÀÉ®×": Exit Sub
    AR = Split(hubopf, "\")
    hubopf = AR(UBound(AR))   'hubopf = "B.xls"ÀHµÛ¶}±ÒÀɦW¤£¦P¤]¥i¯à¬O"C.xls"
    Workbooks.Open hubopf     'Workbooks( hubopf )

¦p±zªº¨ó§U±N¤W­±ªºµ{¦¡½X¨Ï¥Î¤§«á,³v¦æ°õ¦æ¨ì
ActiveCell.FormulaR1C1 = _
        "=IF(AND(RC[-1]=[hubopf]AC8E!R" & hubcn & "C2,[hubopf]AC8E!R" & hubcn & "C72>0,[hubopf]AC8E!R" & hubcn & "C72-SUM(R" & mycarw & "C11:RC[5])>0),[hubopf]AC8E!R" & hubcn & "C9)"

³o¸Ì·|¸õ¥X¹ï¸Ü®Ø­n¨D§Ú¿ï¾Ü¶}±ÒÀÉ®×,¦pªG¤£¿ïÀÉ®×,¦bÀx¦s®æ´N·|§P§OFALSE,¿ï¤FÀɮפ~·|¥X²{§Ú­nªºµ²ªG
§Úµo²{¬Ohubopf¨S¦³­È,©Ò¥H¤S­n¨D­«¶}ÀÉ®×,¥i¬O³o­Óhubopf¬O¤@¶}©l´N«Å§iªº,¨ì¤F¤½¦¡®É«o¤S»Ý­«¶}Àɮפ~¦³­È,
§Úªº¥¨¶°¬O¼g¦bA.xlsªºsheet2 , ¦b¤W­z¤½¦¡°õ¦æ«e¦³¦h¦¸¤Á´«A.xls ©M B.xls , ³o­Ó¤½¦¡¬O¦bA.xlsªºÀx¦s®æ¤¤,
½Ð±Ð¤j¤j,¦p¦ó¤~¯à¤£­n«ùÄò­«¶}ÀÉ®×?

·PÁÂ

TOP

¦^´_ 9# GBKEE
  1. Sub Test()
  2.     Dim hubopf As String, AR
  3.     hubopf = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
  4.     If hubopf = "False" Then MsgBox "½Ð¿ï¨úÀÉ®×": Exit Sub
  5.     AR = Split(hubopf, "\")
  6.     hubopf = AR(UBound(AR))   'hubopf = "B.xls"ÀHµÛ¶}±ÒÀɦW¤£¦P¤]¥i¯à¬O"C.xls"
  7.     Workbooks.Open hubopf     'Workbooks( hubopf )
  8.     Worksheets("AC8E").Cells.Select
  9.     Worksheets("AC8E").Range("A:BY").Sort Key1:=Worksheets("AC8E").Range("D2"), _
  10.     Order1:=xlAscending, Key2:=Worksheets("AC8E").Range("I2") _
  11.     , Order2:=xlAscending, Header:=xlYes
  12.     ThisWorkbook.Activate
  13.     Dim calopf As String
  14.     calopf = ThisWorkbook.Name
  15.     ActiveSheet.Cells.Select
  16.     Selection.Sort Key1:=Range("E2"), Order1:=xlAscending, Key2:=Range("C2"), _
  17.     Order2:=xlAscending, Key3:=Range("A2"), _
  18.     Order3:=xlAscending, Header:=xlYes
  19.     Cells(ActiveSheet.Rows.Count, 6).End(xlUp).Select
  20.     Selection.Offset(1, 0).Select
  21.     Workbooks(hubopf).Worksheets("AC8E").Activate
  22.   Dim hubcn As Integer, hubrwcnt As Integer
  23.    hubrwcnt = ActiveSheet.UsedRange.Rows.Count
  24.   For hubcn = 2 To hubrwcnt - 1
  25.     Workbooks(hubopf).Activate
  26.     Worksheets("AC8E").Range("BT" & hubcn).Select
  27.    If Selection.Value > 0 Then
  28.       Workbooks(calopf).Worksheets("sheet2").Activate
  29.       Dim mycarw As Integer
  30.       mycarw = ActiveCell.Row
  31.       Do
  32.         ActiveCell.FormulaR1C1 = _
  33.         "=IF(AND(RC[-1]=[hubopf]AC8E!R" & hubcn & "C2,[hubopf]AC8E!R" & hubcn & "C72>0,[hubopf]AC8E!R" & hubcn & "C72-SUM(R" & mycarw & "C11:RC[5])>0),[hubopf]AC8E!R" & hubcn & "C9)"
  34.       Selection.Value = Selection.Value
  35.         ActiveCell.Offset(1).Select
  36.       Loop Until ActiveCell.Offset(-1).Value = False
½Æ»s¥N½X
´N¬O³o¼Ë¤lµM«á¨ì¤½¦¡®É´N¤@ª½­n­«¶}ÀÉ®×

TOP

¦^´_ 12# GBKEE


    ·PÁÂGBKEE¤j¤j¨³³t¦^ÂÐ

§ÚÁÙ¨Sµo°Ý«e¤w¦³§ï¹Lª©¤j©Ò±Ðªº¤è¦¡,¦ýÁÙ¬O°õ¦æ¿ù»~,¹ê¦b¬O¨S»³¤F,¥u¦n«pÁy¥Öªº¤@ª½¨Ó³oÃä½Ð±Ð

:L

TOP

¥»©«³Ì«á¥Ñ luffyzoro ©ó 2011-11-24 17:58 ½s¿è

¦^´_ 14# GBKEE
   For hubcn = 2 To hubrwcnt - 1
    Workbooks(hubopf).Activate
    Worksheets("AC8E").Range("BT" & hubcn).Select
   If Selection.Value > 0 Then
      Workbooks(calopf).Worksheets("sheet2").Activate
      Dim mycarw As Integer
      mycarw = ActiveCell.Row
    Do
       ChDir "H:\My documents\±M®×\¤u§@¶q±M®×"        
       ActiveCell.FormulaR1C1 = _
        "=IF(AND(RC[-1]=[" & hubopf & "]AC8E!R" & hubcn & "C2,[" & hubopf & "]AC8E!R" & hubcn & "C72>0,[" & hubopf & "]AC8E!R" & hubcn & "C72-SUM(R" & mycarw & "C11:RC[5])>0),[" & hubopf & "]AC8E!R" & hubcn & "C9)"
        Selection.Value = Selection.Value
        ActiveCell.Offset(1).Select
      Loop Until ActiveCell.Offset(-1).Value = False

·PÁª©¤j
¦ý¬OÁÙ¬O¤@¼Ë¥X°ÝÃD
¿ù»~°T®§  °õ¦æ¶¥¬q¿ù»~'1004':À³¥Îµ{¦¡©Îª«¥ó©w¸q¤Wªº¿ù»~

¤£¦n·N«ä°Ú,ª©¤j
ÂŦ⨺¤@¬q§Ú¬ÝÀx¦s®æ³£¦³¦bhubopf©Ò¥NªíªºÀɮײ¾°Ê
¥i¬O¨ì¤F¤½¦¡¨º¤@¬q´N¥X¿ù¤F
ÁٽбzÀ°¦£¬Ý¤@¤U¬O§_ÁÙ¦³­þÃ䦳°ÝÃD

TOP

¦^´_ 16# GBKEE

½ÐÀˬd¨C¤@  Workbooks (hubopf) ¤¤¬O§_ ¦³¤u§@ªí¦WºÙ"AC8E"

½Ð°Ýª©¤j³o¥y¸Üªº·N«ä¬O«ü¦b¤½¦¡¤¤ªºÁÙ¬O»¡§Ú«ü©wªº¸ê®Æ§¨¨C¤@Àɮ׳£­n¦³¤u§@ªí"AC8E"?

§Ú®³ª©¤j15¼Óªº¦^ÂФ½¦¡¶K¦^§Úªºµ{¦¡½X?¤´µM¥X²{¦P¼Ëªº¿ù»~°T®§

©Î¬O¸Ó¤½¦¡¦³¨S¦³¨ä¥Lªº¼gªk?¯u¤£ª¾¹D¬O­þ¸Ì¦³°ÝÃD?ÀY§ÖÃz¤F>"<

§ÚªºEXCELª©¥»¬O2003¦³®t¶Ü?

¦A¦¸·PÁÂ

TOP

        ÀR«ä¦Û¦b : °µ¸Ó°µªº¨Æ¬O´¼¼z¡A°µ¤£¸Ó°µªº¨Æ¬O·Mè¡C
ªð¦^¦Cªí ¤W¤@¥DÃD