- ©«¤l
 - 835 
 - ¥DÃD
 - 6 
 - ºëµØ
 - 0 
 - ¿n¤À
 - 915 
 - ÂI¦W
 - 1  
 - §@·~¨t²Î
 - Win 10,7 
 - ³nÅ骩¥»
 - 2019,2013,2003 
 - ¾\ŪÅv
 - 50 
 - ©Ê§O
 - ¨k 
 - µù¥U®É¶¡
 - 2010-5-3 
 - ³Ì«áµn¿ý
 - 2025-7-5 
 
  | 
                
 ¥»©«³Ì«á¥Ñ luhpro ©ó 2019-11-17 01:17 ½s¿è  
¦^´_  luhpro  
 
½Ð°Ý¤j¤j, 
¤@¯ë§Ú¦b¥ÎVBA®É,¥ÎAlt + F11´N¥i¥H¬Ý¨ìModuleªºµ{¦¡½X,¬°¤°»ò±z¼gªºµ{¦¡¬Ý¤£¨ìModule ? 
 
PJChen µoªí©ó 2019-11-16 23:12    
¨º¥u¬O§Ú̪º¤Á´«¤è¦¡¤£¦P, 
§A¥unÂI¤@¤U¦p¤U¹Ïªº "À˵øµ{¦¡½X" «ö¶s´N¥i¥H¬Ý¨ì¤F. 
 
 
 
 
¥t¥~¦]¬°ªí®æ¤@¶}©lªºª¬ºA³£¬OªÅ¥Õªº,¶ñ¤J¸ê®Æ®Én±q²Ä3¦C¶}©l,¦ý¦b´ú¸Õ®É³£·|±q²Ä6¦C¶}©l¶ñ,¥i§_À°¦£§ï¬°°_©l¥Ñ²Ä3¦C¶}©l¼g¤J¸ê®Æ?  
¦]¬°§Aªº½d¨Ò¾×¬Ý¨ìªº¬O±q²Ä6¦C¶}©lªº.(ÁôÂäF²Ä3-5¦C) 
»Ýnק侀¤U³o¦æ¼Æ¦r : 
    With wsTar ' ²£¥Í¼t¯Êªí 
    .Range(.[A6], .Cells(Rows.Count, 8)).Delete Shift:=xlShiftUp 
    lRow = 3 
    For Each vA In diPro 
ÁÙ¦³©³¤U³o¦æ : 
     lRow = lRow - 1 
    With .Range(.[B3, .Cells(lRow, 7)) 
       .Borders(xlEdgeLeft).LineStyle = xlContinuous 
 
¥t¥~§Úªºµ{¦¡n©ñ¦b¥t¤@ÀÉ®×Macro.xlsm¤¤°õ¦æ,¨Ã«ü©wÀɦW"³Ì·s®w¦s.xlsx"½Ð°Ýµ{¦¡n«ç»ò×¥¿?  
  Dim sStr$, sPath$, sFlName$ 
... 
  Set wsSou = ThisWorkbook.Sheets("¥X³f") 
  Set wsTar = Sheets("¼t¯Êªí")  <=§R±¼³o¦æ 
  Set diPro = CreateObject("Scripting.Dictionary") ' °Ó«~¯Ê¼Æ   
   sPath = ThisWorkbook.Path ' ¦pªGn«ü©w¥Ø¿ý, ¥un§ï¦¨¸Ó¥Ø¿ý§Y¥i, ¦p sPath = "D:" 
  sFlName = "³Ì·s®w¦s.xlsx" 
  bMatch = False ' Àˬd '³Ì·s®w¦s.xlsx' Àɮ׬O§_¤w¶}±Ò 
  For iI = 1 To Workbooks.Count 
    If Workbooks(iI).Name = sFlName Then 
      bMatch = True 
      Exit For 
    End If 
  Next iI 
  If bMatch Then 
    Set wsTar = Workbooks(sFlName).Sheets("¼t¯Êªí") 
    wsTar.Activate 
  Else 
    Set wsTar = Workbooks.Open(Filename:=sPath & "\" & sFlName).Sheets("¼t¯Êªí") 
  End If  
³Ì«á, ì¥ýªºÀɮפ¤, 
¦r§Î¤j¤p»P½c¤J¼ÆÃC¦â§Ñ¤F§ï, 
´N¤@¨Ö³B²z¤F : 
     With .Range(.[B3], .Cells(lRow, 7)) 
      .Font.Size = 18 
   ... 
    End With 
    For Each vA In diTit 
... 
    Next 
    With .Range(.[D3], .Cells(lRow, 3)) 
      .Font.ColorIndex = 23 
    End With 
 
×§ï«á§¹¾ãµ{¦¡¦p¤U : 
Private Sub CbCreat_Click() ' ²£¥Í©ú²Ó 
  Dim iI%, iCol% 
  Dim lRow& 
  Dim sStr$, sPath$, sFlName$ 
  Dim bMatch As Boolean 
  Dim diPro, diTit, vA, vD1, vD2 
  Dim wsSou As Worksheet, wsTar As Worksheet 
   
  Set wsSou = ThisWorkbook.Sheets("¥X³f") 
  Set diPro = CreateObject("Scripting.Dictionary") ' °Ó«~¯Ê¼Æ 
  Set diTit = CreateObject("Scripting.Dictionary") ' ¾ÚÂI¦C¼Æ 
   
  sPath = ThisWorkbook.Path ' ¦pªGn«ü©w¥Ø¿ý, ¥un§ï¦¨¸Ó¥Ø¿ý§Y¥i, ¦p sPath = "D:" 
  sFlName = "³Ì·s®w¦s.xlsx" 
  bMatch = False ' Àˬd '³Ì·s®w¦s.xlsx' Àɮ׬O§_¤w¶}±Ò 
  For iI = 1 To Workbooks.Count 
    If Workbooks(iI).Name = sFlName Then 
      bMatch = True 
      Exit For 
    End If 
  Next iI 
  If bMatch Then 
    Set wsTar = Workbooks(sFlName).Sheets("¼t¯Êªí") 
    wsTar.Activate 
  Else 
    Set wsTar = Workbooks.Open(Filename:=sPath & "\" & sFlName).Sheets("¼t¯Êªí") 
  End If 
   
  With wsSou ' Ū¨ú¥X³f¸ê®Æ 
    iCol = 45 '¼t¯Ê°_©l¦æ 
    While .Cells(3, iCol) <> "" 
      sStr = .Cells(3, iCol) ' ¾ÚÂI¦W 
      lRow = 4 '°Ó«~°_©l¦C 
      While .Cells(lRow, 8) <> "" ' °Ó«~¦WºÙ 
        If .Cells(lRow, iCol) > 0 Then 
          If diPro.Exists(sStr) Then 
            diPro(sStr) = diPro(sStr) & "," & lRow & "-" & .Cells(lRow, iCol) 
          Else 
            diPro(sStr) = lRow & "-" & .Cells(lRow, iCol) 
          End If 
        End If 
        lRow = lRow + 1 
      Wend 
      iCol = iCol + 1 
    Wend 
  End With 
 
  With wsTar ' ²£¥Í¼t¯Êªí 
    .Range(.[A6], .Cells(Rows.Count, 8)).Delete Shift:=xlShiftUp 
    lRow = 3 
    For Each vA In diPro 
      With .Cells(lRow, 2).Resize(, 6) ' ¾ÚÂI¦W 
        With .Cells(1) 
          .Value = vA 
          diTit(vA) = lRow 
          .HorizontalAlignment = xlCenter 
          .VerticalAlignment = xlCenter 
          With .Font 
            .Size = 22 
            .Bold = False 
          End With 
        End With 
         
        With .Interior 
            .Pattern = xlPatternLinearGradient 
            .Gradient.Degree = 90 
            .Gradient.ColorStops.Clear 
          With .Gradient.ColorStops.Add(0) 
            .ThemeColor = xlThemeColorDark1 
            .TintAndShade = 0 
          End With 
          With .Gradient.ColorStops.Add(1) 
            .Color = 118671 
            .TintAndShade = 0 
          End With 
        End With 
      End With 
      lRow = lRow + 1 
       
      sStr = diPro(vA) 
      vD1 = Split(sStr, ",") 
      For iI = 0 To UBound(vD1) 
        vD2 = Split(vD1(iI), "-") 
        .Cells(lRow, 1) = wsSou.Cells(vD2(0), 6) ' ®Æ¸¹ 
        .Cells(lRow, 2) = wsSou.Cells(vD2(0), 8) ' °Ó«~¦WºÙ 
        .Cells(lRow, 4) = wsSou.Cells(vD2(0), 7) ' ½c¤J¼Æ 
        .Cells(lRow, 5) = vD2(1) ' ¤í²~¼Æ 
        .Cells(lRow, 6) = Int(vD2(1) / .Cells(lRow, 4)) ' ½c 
        .Cells(lRow, 7) = vD2(1) Mod .Cells(lRow, 4) ' ²~ 
        .Cells(lRow, 8) = wsSou.Cells(vD2(0), 5) ' ½¦±a 
        lRow = lRow + 1 
      Next 
    Next 
     
    lRow = lRow - 1 
    With .Range(.[B3], .Cells(lRow, 7)) 
      .Font.Size = 18 
      .Borders(xlEdgeLeft).LineStyle = xlContinuous 
      .Borders(xlEdgeTop).LineStyle = xlContinuous 
      .Borders(xlEdgeBottom).LineStyle = xlContinuous 
      .Borders(xlEdgeRight).LineStyle = xlContinuous 
      .Borders(xlInsideVertical).LineStyle = xlContinuous 
      .Borders(xlInsideHorizontal).LineStyle = xlContinuous 
    End With 
    For Each vA In diTit 
      With .Cells(diTit(vA), 2).Resize(, 6) 
        .Borders(xlInsideVertical).LineStyle = xlNone 
        .Borders(xlInsideHorizontal).LineStyle = xlNone 
      End With 
    Next 
    With .Range(.[D3], .Cells(lRow, 3)) 
      .Font.ColorIndex = 23 
    End With 
  End With 
  MsgBox "¯Ê®Æ©ú²Ó¤w²£¥Í§¹²¦..." 
End Sub 
  ¦Û°Ê®Mªí-Ans2.zip (56.31 KB)
 |   
 
 
 
 |