ªð¦^¦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

¦^´_ 1# luffyzoro

¿ý»s¥¨¶°ªº¤½¦¡¬O¥HR1C1°Ñ·Ó§Î¦¡
R«á­±ªº¼Æ­È¬Oªí¥Ü¦C¦ì¡A·íR«á­±¨S¦³¼Æ­Èªí¥Ü»P¤½¦¡©Ò¦bÀx¦s®æ¦P¦C¡A¼Æ­È¥H¤¤¬A¸¹¼Ð¥Üªí¥Ü¬Û¹ï°Ñ·Ó©ó¤½¦¡©Ò¦bÀx¦s®æªº¦C¼Æ¡C
C«á­±ªº¼Æ­È¬Oªí¥ÜÄæ¦ì¡A·íC«á­±¨S¦³¼Æ­Èªí¥Ü»P¤½¦¡©Ò¦bÀx¦s®æ¦PÄæ¡A¼Æ­È¥H¤¤¬A¸¹¼Ð¥Üªí¥Ü¬Û¹ï°Ñ·Ó©ó¤½¦¡©Ò¦bÀx¦s®æªºÄæ¼Æ¡C   
¦Ó¤½¦¡¦bVBA¤¤¬O¤@­Ó¦r¦ê«¬ºAªº¸ê®Æ
¨Ò¦p:R2C24³o¬O«ü¨ìX2Àx¦s®æ
­Y¬OÄæ¦ì­nÅÜ°Ê¡A¥ý¥HÅܼƫü©wÄæ¦ìµM«á±a¤J¦r¦ê
k=26
"R2C" & k
³o¼Ë±o¨ì¦r¦ê´N¬OR2C26
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¥»©«³Ì«á¥Ñ 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

¦^´_ 4# luffyzoro


    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)"
¾Ç®üµL²P_¤£®¢¤U°Ý

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

¦^´_ 6# luffyzoro

Dim hubopf As String
hubopf = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
If hubopf = "False" Then MsgBox "½Ð¿ï¨úÀÉ®×": Exit Sub
Workbooks.Open hubopf
¾Ç®üµL²P_¤£®¢¤U°Ý

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

¦^´_ 8# luffyzoro
  1. Option Explicit
  2. Sub Ex()
  3.     Dim hubopf As String, AR
  4.     hubopf = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
  5.     If hubopf = "False" Then MsgBox "½Ð¿ï¨úÀÉ®×": Exit Sub
  6.     AR = Split(hubopf, "\")
  7.     hubopf = AR(UBound(AR))   'hubopf = "B.xls"ÀHµÛ¶}±ÒÀɦW¤£¦P¤]¥i¯à¬O"C.xls"
  8.     Workbooks.Open hubopf     'Workbooks( hubopf )
  9. End Sub
½Æ»s¥N½X

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

        ÀR«ä¦Û¦b : ¤@­Ó¯Ê¤fªºªM¤l¡A¦pªG´«¤@­Ó¨¤«×¬Ý¥¦¡A¥¦¤´µM¬O¶êªº¡C
ªð¦^¦Cªí ¤W¤@¥DÃD