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

[µo°Ý] VBA¤¤ªº¨ç¼Æ¦¡ ¨ú¥N

[µo°Ý] VBA¤¤ªº¨ç¼Æ¦¡ ¨ú¥N

¥»©«³Ì«á¥Ñ PJChen ©ó 2020-3-1 18:00 ½s¿è

Dear,
¦b¤u§@ªí¤¤¥i¥H¦Û©w¸q¨ç¼Æ¨Ï¤½¦¡Åܱo²¼ä,¦ý¦]¬°¥Î±o¤Ó¦h¤F,·í»Ý­n­×§ï®É,¤]¬O«Ü¥O¤H²V²c...
·Q§ï¦b¼gµ{¦¡®É,§â¤½¦¡¥Î¤@­Ó¥N½Xxcªí¥Ü,³Ì«áÅܦ¨­È,³o¼Ë´N¤£¥Î¤@ª½§â¤¾ªøªº¨ç¼Æ¦¡¼g¥X¨Ó,¦ý¬O"¦æ¤£³q",
½Ð°Ý¬O§_¦³¨ä¥Lªº¼gªkor»Ý­n¤°»òª«¥ó,¸Õ¤F¤S¸ÕÁ`¬O¤£¦æ..
                i = "C1:J1"
                    xcol = Range(i).Columns.Count
                    Set xc = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=¬d±b!$B$3)*(­¸¤ñ!$AP$3:$BH$3=¬d±b!C4)*(¤ñµá¦h!$AP$4:$BH$70))" '¬d±b_­qÁʼÆ
                        .Range("C5").Resize(1, xcol).Value = "=" & xc
                        .Range("C5").Resize(1, xcol).Value = .Range("C5").Resize(1, xcol).Value

¦^´_ 13# ­ã´£³¡ªL

·PÁ­ã¤jÀ°§Ú°_¤F¤@­ÓÀY,¥Ñ©ó¾ã­Ó¬d±b¤º®eÁÙ¤£§¹¾ã,³Ñ¾lªº¸ê®Æ,§Ú¦A¬Ý¬Ý¯à§_¨Ì¼Ëµe¸¬Äªµ¹¸É¤W~~ÁÂÁÂ

TOP

Sub ¤½¦¡_01()
Dim xR As Range, xH As Range, xA As Range, C%, N&
Set xR = [C5] '²Ä¤@°Ï©w¦ì®æ
C = Application.Match("¦X­p", Rows(4), 0) - xR.Column  'Äæ¦ì¼Æ
Set xA = xR.Resize(7, C) '²Ä¤@°Ï(¤£§t¦X­pÄæ)
Application.ScreenUpdating = False
xA = "=IF(C4=0,"""",INT(C4/$C$3)&""½c""&TEXT(MOD(C4,$C$3),""+0;;;""))"
xA.Rows(1) = "=SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$AP$3:$BH$3=C4)*(­¸¤ñ!$AP$4:$BH$70))"
xA.Rows(3) = "=SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$BJ$3:$CB$3=C4)*(­¸¤ñ!$BJ$4:$CB$70))"
xA.Rows(5) = "=SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$CD$3:$CV$3=C4)*(­¸¤ñ!$CD$4:$CV$70))"
xA.Rows(6) = "=SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$CX$3:$DP$3=C4)*(­¸¤ñ!$CX$4:$DP$70))"
xR(1, C + 1).Resize(7) = "=IF($B5=""½c+²~"","""",SUM(" & xA.Rows(1).Address(0, 0) & "))" '¦X­pÄæ
'-----------------------------------------------
Set xA = xR.Resize(7, C + 1) '²Ä¤@°Ï(§t¦X­pÄæ)
Do
    N = N + 1: Set xH = xR(N * 9 + 1, 1)
    If xH(1, 0) <> "­qÁʼÆ" Then Exit Do
    With xH.Resize(7, C + 1)
         xA.Copy .Cells
         .Value = .Value
    End With
Loop
xA.Value = xA.Value
End Sub

Xl0000048.rar (35.95 KB)

======================================

TOP

¦^´_ 11# jcchiang

­ì¨Ó¬O¥X¦bÂù¤Þ¸¹,·PÁÂ,,,§Ú¦A¸Õ¸Õ

TOP

¦^´_ 10# PJChen
Àx¦s®æ¤½¦¡¤¤E3="",­n¼g¦¨E3=""""

1) µLªk°õ¦æ
xRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Range("E3:E" & xRow).Formula = "=IF(E3="""",""µL¥æ³f"",T3&S3&R3)"
2)µLªk°õ¦æ
Range("Z3:Z" & xRow).Formula = "=IF(AB3="""","""",AB3-Y3)"

3) µLªk°õ¦æ
Range("F2:F" & xRow).Formula = "=IF(MONTH(A3)<>MONTH(A4),SUM(INDIRECT(ADDRESS(MATCH(DATE(YEAR(A3),MONTH(A3),1),A:A,0),COLUMN(D3),3)):D3),"""")"

TOP

¦^´_ 9# jcchiang

¥»·Q§ïµ½ªí®æ,Åý¥¦Â²¼ä¤SRUN§Ö¨Ç,¦n¹³¸£³UÅܱo§ó·Q¤£²M·¡¤F...
¥ý½Ð±Ð¥t­Ó¤½¦¡°ÝÃD,§Ö§â§Ú·dºÆ¤F....
¥H¤U3­Ó¤½¦¡,ª½±µkey¦bÀx¦s®æ®É³£¨S°ÝÃD,¦ý¬°¤°»ò¦bVBA¤¤,§¹¥þµLªk°õ¦æ?
1) µLªk°õ¦æ
xRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Range("E3:E" & xRow).Formula = "=IF(E3="",""µL¥æ³f"",T3&S3&R3)"
2)µLªk°õ¦æ
Range("Z3:Z" & xRow).Formula = "=IF(AB3="","",AB3-Y3)"

3) µLªk°õ¦æ
Range("F2:F" & xRow).Formula = "=IF(MONTH(A3)<>MONTH(A4),SUM(INDIRECT(ADDRESS(MATCH(DATE(YEAR(A3),MONTH(A3),1),A:A,0),COLUMN(D3),3)):D3),"")"

TOP

¦^´_ 7# PJChen
¿@ÁY¤@¤U,2ºØ¼gªk´£¨Ñ°Ñ¦Ò
¬d±b_­qÁʽc²~ = "=" & "IF(C5=0,"",INT(C5/$C$3)&IF(MOD(C5,$C$3)=0,""½c"",""½c+""&MOD(C5,$C$3)))"
¬d±b_¼t¯Ê½c²~ = "=" & "IF(C7=0,"",INT(C7/$C$3)&""½c"")&IF(MOD(C7,$C$3)=0,"",""+""&MOD(C7,$C$3))"'
¬d±b_¹ê¥X½c²~ = "=" & "IF(C10=0,"",INT(C10/$C$3)&""½c"")&IF(MOD(C10,$C$3)=0,"",""+""&MOD(C10,$C$3))"
³o¤T­Ó¤½¦¡À³¸Ó¤@¼Ë,¥u¬O­pºâ¦ì¸m¤£¦P,²Î¤@¨Ï¥Î"¬d±b_­qÁʽc²~"ªº¤½¦¡,­pºâ¦ì¸m·|§ó°Ê
©Ò¥HEXCEL¤ººû«ù¥Î"½c+²~"§PÂ_

Sub ex1()
i = "C1:J1"
xcol = Range(i).Columns.Count  '¬Ý´Xµ§¸ê®Æ
For Each x In Range([b2], [b65535].End(3)) 'Range("B1:b20")
r = x.Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False)
   If x = "­qÁʼÆ" Then
      ¬d±b_­qÁÊ¼Æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$AP$3:$BH$3= " & r & ")*(­¸¤ñ!$AP$4:$BH$70))"
      Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = ¬d±b_­qÁʼÆ
   ElseIf x = "½c+²~" Then
      ¬d±b_­qÁʽc²~ = "=" & "IF(" & r & "=0,"""",INT(" & r & "/$C$3)&IF(MOD(" & r & ",$C$3)=0,""½c"",""½c+""&MOD(" & r & ",$C$3)))"
      Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = ¬d±b_­qÁʽc²~
   ElseIf x = "¼t¯Ê" Then
      r1 = Range(r).Offset(-2, 0).Address(RowAbsolute:=False, columnAbsolute:=False)
      ¬d±b_¼t¯Ê = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$BJ$3:$CB$3=" & r1 & ")*(­¸¤ñ!$BJ$4:$CB$70))"
      Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¼t¯Ê
   ElseIf x = "¹º³æ" Then
      r1 = Range(r).Offset(-4, 0).Address(RowAbsolute:=False, columnAbsolute:=False)
      ¬d±b_¹º³æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$CD$3:$CV$3=" & r1 & ")*(­¸¤ñ!$CD$4:$CV$70))"
      Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¹º³æ
   ElseIf x = "¹ê¥X¼Æ" Then
      r1 = Range(r).Offset(-5, 0).Address(RowAbsolute:=False, columnAbsolute:=False)
      ¬d±b_¹ê¥X¼Æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$CX$3:$DP$3=" & r1 & ")*(­¸¤ñ!$CX$4:$DP$70))"
      Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¹ê¥X¼Æ
   End If
Next
Range("C1").Resize(Range("C65535").End(3).Row, xcol).Value = Range("C1").Resize(Range("C65535").End(3).Row, xcol).Value 'Âର¼Æ­È
End Sub
-----------------------------------------------------------------------------------------------
Sub ex2()
i = "C1:J1"
xcol = Range(i).Columns.Count  '¬Ý´Xµ§¸ê®Æ
x = 2
Do While x < Range("B65535").End(3).Row + 1
   r = Cells(x, "B").Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False)
   Select Case Cells(x, "B")
      Case Is = "­qÁʼÆ"
         ¬d±b_­qÁÊ¼Æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$AP$3:$BH$3= " & r & ")*(­¸¤ñ!$AP$4:$BH$70))"
         Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = ¬d±b_­qÁʼÆ
      Case Is = "½c+²~"
         ¬d±b_­qÁʽc²~ = "=" & "IF(" & r & "=0,"""",INT(" & r & "/$C$3)&IF(MOD(" & r & ",$C$3)=0,""½c"",""½c+""&MOD(" & r & ",$C$3)))"
         Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = ¬d±b_­qÁʽc²~
      Case Is = "¼t¯Ê"
         r1 = Range(r).Offset(-2, 0).Address(RowAbsolute:=False, columnAbsolute:=False)
         ¬d±b_¼t¯Ê = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$BJ$3:$CB$3=" & r1 & ")*(­¸¤ñ!$BJ$4:$CB$70))"
         Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¼t¯Ê
      Case Is = "¹º³æ"
         r1 = Range(r).Offset(-4, 0).Address(RowAbsolute:=False, columnAbsolute:=False)
         ¬d±b_¹º³æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$CD$3:$CV$3=" & r1 & ")*(­¸¤ñ!$CD$4:$CV$70))"
         Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¹º³æ
      Case Is = "¹ê¥X¼Æ"
         r1 = Range(r).Offset(-5, 0).Address(RowAbsolute:=False, columnAbsolute:=False)
        ¬d±b_¹ê¥X¼Æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$CX$3:$DP$3=" & r1 & ")*(­¸¤ñ!$CX$4:$DP$70))"
        Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¹ê¥X¼Æ
   End Select
   x = x + 1
Loop
Range("C1").Resize(Range("C65535").End(3).Row, xcol).Value = Range("C1").Resize(Range("C65535").End(3).Row, xcol).Value 'Âର¼Æ­È
End Sub

TOP

¦^´_ 7# PJChen
2ºØ¼gªk´£¨Ñ°Ñ¦Ò
¦]¬°©pªº¤½¦¡¤Ó¦h¼Ë,¥ý¨Ì¦U¶µÄæ¦ì¶ñ¼g,¦p¦³¥i¥H¦X¨Ö½Ð¦Û¦æ½Õ¾ã
½c+²~­×§ï¬°½c+²~(1)/½c+²~(2)/½c+²~(3),¥H«K§PÂ_(Excel¤º®e½Ð­×¥¿)
½c+²~(1)--­qÁʼÆ
½c+²~(2)--¼t¯Ê
½c+²~(3)--¹ê¥X¼Æ
Âର¼Æ­È¤@¨Ö©óµ{¦¡«áÂà´«(³v¶µÂà´«µ{¦¡«O¯d,»Ý­n¦Û¦æ¶}±Ò)
¥\¤O¨S«Ü¦n,¬O§_ÁٯತÆ,´N½Ð¨ä¥L°ª¤âÀ°¦£¤F

Sub ex1()
'¬d±b_­qÁÊ¼Æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$AP$3:$BH$3=C4)*(­¸¤ñ!$AP$4:$BH$70))"
'¬d±b_­qÁʽc²~ = "=" & "IF(C5=0,"",INT(C5/$C$3)&IF(MOD(C5,$C$3)=0,""½c"",""½c+""&MOD(C5,$C$3)))"
'¬d±b_¼t¯Ê = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$BJ$3:$CB$3=C4)*(­¸¤ñ!$BJ$4:$CB$70))"
'¬d±b_¼t¯Ê½c²~ = "=" & "IF(C7=0,"",INT(C7/$C$3)&""½c"")&IF(MOD(C7,$C$3)=0,"",""+""&MOD(C7,$C$3))"'
'¬d±b_¹º³æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$CD$3:$CV$3=C4)*(­¸¤ñ!$CD$4:$CV$70))"
'¬d±b_¹ê¥X¼Æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$CX$3:$DP$3=C4)*(­¸¤ñ!$CX$4:$DP$70))"
'¬d±b_¹ê¥X½c²~ = "=" & "IF(C10=0,"",INT(C10/$C$3)&""½c"")&IF(MOD(C10,$C$3)=0,"",""+""&MOD(C10,$C$3))"
i = "C1:J1"
xcol = Range(i).Columns.Count  '¬Ý´Xµ§¸ê®Æ
For Each x In Range([b1], [b65535].End(3)) 'Range("B1:b20")
   If x = "­qÁʼÆ" Then
      ¬d±b_­qÁÊ¼Æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$AP$3:$BH$3= " & _
                    x.Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & ")*(­¸¤ñ!$AP$4:$BH$70))"
      Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = ¬d±b_­qÁʼÆ
   '  Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = Range(x.Address).Offset(0, 1).Resize(1, xcol).Value
   ElseIf x = "½c+²~(1)" Then
      ¬d±b_­qÁʽc²~ = "=" & "IF(" & x.Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                      "=0,"""",INT(" & x.Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                      "/$C$3)&IF(MOD(" & x.Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                      ",$C$3)=0,""½c"",""½c+""&MOD(" & x.Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & ",$C$3)))"
      Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = ¬d±b_­qÁʽc²~
   '  Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = Range(x.Address).Offset(0, 1).Resize(1, xcol).Value
   ElseIf x = "¼t¯Ê" Then
      ¬d±b_¼t¯Ê = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$BJ$3:$CB$3=" & _
                  x.Offset(-3, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & ")*(­¸¤ñ!$BJ$4:$CB$70))"
      Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¼t¯Ê
  '   Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = Range(x.Address).Offset(0, 1).Resize(1, xcol).Value
   ElseIf x = "½c+²~(2)" Then
      ¬d±b_¼t¯Ê½c²~ = "=" & "IF(" & x.Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                      "=0,"""",INT(" & x.Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                      "/$C$3)&""½c"")&IF(MOD(" & x.Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                      ",$C$3)=0,"""",""+""&MOD(" & x.Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & ",$C$3))"
      Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¼t¯Ê½c²~
   '  Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = Range(x.Address).Offset(0, 1).Resize(1, xcol).Value
   ElseIf x = "¹º³æ" Then
      ¬d±b_¹º³æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$CD$3:$CV$3=" & _
                   x.Offset(-5, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & ")*(­¸¤ñ!$CD$4:$CV$70))"
      Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¹º³æ
'    Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = Range(x.Address).Offset(0, 1).Resize(1, xcol).Value
   ElseIf x = "¹ê¥X¼Æ" Then
      ¬d±b_¹ê¥X¼Æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$CX$3:$DP$3=" & _
                    x.Offset(-6, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & ")*(­¸¤ñ!$CX$4:$DP$70))"
      Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¹ê¥X¼Æ
'    Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = Range(x.Address).Offset(0, 1).Resize(1, xcol).Value
   ElseIf x = "½c+²~(3)" Then
      ¬d±b_¹ê¥X½c²~ = "=" & "IF(" & x.Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                      "=0,"""",INT(" & x.Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                     "/$C$3)&""½c"")&IF(MOD(" & x.Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                     ",$C$3)=0,"""",""+""&MOD(" & x.Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                     ",$C$3))"
      Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¹ê¥X½c²~
  '   Range(x.Address).Offset(0, 1).Resize(1, xcol).Value = Range(x.Address).Offset(0, 1).Resize(1, xcol).Value
   End If
Next
Range("C1").Resize(Range("C65535").End(3).Row, xcol).Value = Range("C1").Resize(Range("C65535").End(3).Row, xcol).Value '¤@¨ÖÂର¼Æ­È
End Sub

----------------------------------------------------------------------------------------------------------------------------------------------
Sub ex2()
i = "C1:J1"
xcol = Range(i).Columns.Count  '¬Ý´Xµ§¸ê®Æ
x = 1
Do While x < Range("B65535").End(3).Row + 1
   Select Case Cells(x, "B")
      Case Is = "­qÁʼÆ"
         ¬d±b_­qÁÊ¼Æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$AP$3:$BH$3= " & _
                      Cells(x, "B").Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & ")*(­¸¤ñ!$AP$4:$BH$70))"
         Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = ¬d±b_­qÁʼÆ
    '    Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value
      Case Is = "½c+²~(1)"
         ¬d±b_­qÁʽc²~ = "=" & "IF(" & Cells(x, "B").Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                         "=0,"""",INT(" & Cells(x, "B").Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                         "/$C$3)&IF(MOD(" & Cells(x, "B").Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                         ",$C$3)=0,""½c"",""½c+""&MOD(" & Cells(x, "B").Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & ",$C$3)))"
         Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = ¬d±b_­qÁʽc²~
    '    Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value
      Case Is = "¼t¯Ê"
         ¬d±b_¼t¯Ê = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$BJ$3:$CB$3=" & _
                     Cells(x, "B").Offset(-3, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & ")*(­¸¤ñ!$BJ$4:$CB$70))"
         Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¼t¯Ê
   '     Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value
      Case Is = "½c+²~(2)"
         ¬d±b_¼t¯Ê½c²~ = "=" & "IF(" & Cells(x, "B").Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                         "=0,"""",INT(" & Cells(x, "B").Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                         "/$C$3)&""½c"")&IF(MOD(" & Cells(x, "B").Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                         ",$C$3)=0,"""",""+""&MOD(" & Cells(x, "B").Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & ",$C$3))"
         Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¼t¯Ê½c²~
    '    Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value
      Case Is = "¹º³æ"
         ¬d±b_¹º³æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$CD$3:$CV$3=" & _
                     Cells(x, "B").Offset(-5, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & ")*(­¸¤ñ!$CD$4:$CV$70))"
         Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¹º³æ
    '    Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value
      Case Is = "¹ê¥X¼Æ"
        ¬d±b_¹ê¥X¼Æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$CX$3:$DP$3=" & _
                     Cells(x, "B").Offset(-6, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & ")*(­¸¤ñ!$CX$4:$DP$70))"
        Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¹ê¥X¼Æ
   '    Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value
      Case Is = "½c+²~(3)"
        ¬d±b_¹ê¥X½c²~ = "=" & "IF(" & Cells(x, "B").Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                        "=0,"""",INT(" & Cells(x, "B").Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                        "/$C$3)&""½c"")&IF(MOD(" & Cells(x, "B").Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                        ",$C$3)=0,"""",""+""&MOD(" & Cells(x, "B").Offset(-1, 1).Address(RowAbsolute:=False, columnAbsolute:=False) & _
                        ",$C$3))"
        Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = ¬d±b_¹ê¥X½c²~
    '   Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value = Cells(x, "B").Offset(0, 1).Resize(1, xcol).Value
   End Select
   x = x + 1
Loop
Range("C1").Resize(Range("C65535").End(3).Row, xcol).Value = Range("C1").Resize(Range("C65535").End(3).Row, xcol).Value '¤@¨ÖÂର¼Æ­È

End Sub

TOP

¥»©«³Ì«á¥Ñ PJChen ©ó 2020-3-2 19:00 ½s¿è

¦^´_ 6# PJChen
³o¼Ë°µ,¸ê®ÆÁÙ¬O¿ù吔...°£¤FC5¤@¾ã¦Cªº¸ê®Æ¥¿½T,¨ä¾l³s°õ¦æ³£¦³°ÝÃD,¥d¦í¤F...
  1. ¬d±b_­qÁÊ¼Æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$AP$3:$BH$3=C4)*(­¸¤ñ!$AP$4:$BH$70))"
  2. ¬d±b_­qÁʽc²~ = "=" & "IF(C5=0,"",INT(C5/$C$3)&IF(MOD(C5,$C$3)=0,""½c"",""½c+""&MOD(C5,$C$3)))"
  3. ¬d±b_¼t¯Ê = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$BJ$3:$CB$3=C4)*(­¸¤ñ!$BJ$4:$CB$70))"
  4. ¬d±b_¼t¯Ê½c²~ = "=" & "IF(C7=0,"",INT(C7/$C$3)&""½c"")&IF(MOD(C7,$C$3)=0,"",""+""&MOD(C7,$C$3))"
  5. ¬d±b_¹º³æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$CD$3:$CV$3=C4)*(­¸¤ñ!$CD$4:$CV$70))"
  6. ¬d±b_¹ê¥X¼Æ = "=" & "SUMPRODUCT((­¸¤ñ!$F$4:$F$70=$B$3)*(­¸¤ñ!$CX$3:$DP$3=C4)*(­¸¤ñ!$CX$4:$DP$70))"
  7. ¬d±b_¹ê¥X½c²~ = "=" & "IF(C10=0,"",INT(C10/$C$3)&""½c"")&IF(MOD(C10,$C$3)=0,"",""+""&MOD(C10,$C$3))"

  8.                     i = "C1:J1"
  9.                     xcol = Range(i).Columns.Count  '¬Ý´Xµ§¸ê®Æ
  10.                         .Range("C5").Resize(1, xcol).Value = ¬d±b_­qÁʼÆ
  11.                         .Range("C5").Resize(1, xcol).Value = .Range("C5").Resize(1, xcol).Value
  12.                             .Range("C14").Resize(xcol, xcol).Value = ¬d±b_­qÁʼÆ
  13.                             .Range("C14").Resize(xcol, xcol).Value = .Range("C14").Resize(xcol, xcol).Value
  14.                            
  15.                                 .Range("C6").Resize(1, xcol).Value = ¬d±b_­qÁʽc²~
  16.                                 .Range("C6").Resize(1, xcol).Value = .Range("C6").Resize(1, xcol).Value
  17.                                     .Range("C15").Resize(xcol, xcol).Value = ¬d±b_­qÁʽc²~
  18.                                     .Range("C15").Resize(xcol, xcol).Value = .Range("C15").Resize(xcol, xcol).Value
  19.                                     
  20.                                         .Range("C7").Resize(1, xcol).Value = ¬d±b_¼t¯Ê
  21.                                         .Range("C7").Resize(1, xcol).Value = .Range("C7").Resize(1, xcol).Value
  22.                                             .Range("C16").Resize(xcol, xcol).Value = ¬d±b_¼t¯Ê
  23.                                             .Range("C16").Resize(xcol, xcol).Value = .Range("C16").Resize(xcol, xcol).Value
  24.                                             
  25.                                                 .Range("C8").Resize(1, xcol).Value = ¬d±b_¼t¯Ê½c²~
  26.                                                 .Range("C8").Resize(1, xcol).Value = .Range("C8").Resize(1, xcol).Value
  27.                                             .Range("C17").Resize(xcol, xcol).Value = ¬d±b_¼t¯Ê½c²~
  28.                                             .Range("C17").Resize(xcol, xcol).Value = .Range("C17").Resize(xcol, xcol).Value
  29.                                         .Range("C9").Resize(xcol, xcol).Value = ¬d±b_¹º³æ
  30.                                         .Range("C9").Resize(xcol, xcol).Value = .Range("C9").Resize(xcol, xcol).Value
  31.                                     .Range("C10").Resize(xcol, xcol).Value = ¬d±b_¹ê¥X¼Æ
  32.                                     .Range("C10").Resize(xcol, xcol).Value = .Range("C10").Resize(xcol, xcol).Value
  33.                                 .Range("C19").Resize(xcol, xcol).Value = ¬d±b_¹ê¥X¼Æ
  34.                                 .Range("C19").Resize(xcol, xcol).Value = .Range("C19").Resize(xcol, xcol).Value
  35.                             .Range("C11").Resize(xcol, xcol).Value = ¬d±b_¹ê¥X½c²~
  36.                             .Range("C11").Resize(xcol, xcol).Value = .Range("C11").Resize(xcol, xcol).Value
  37.                         .Range("C20").Resize(xcol, xcol).Value = ¬d±b_¹ê¥X½c²~
  38.                         .Range("C20").Resize(xcol, xcol).Value = .Range("C20").Resize(xcol, xcol).Value
½Æ»s¥N½X

TOP

¦^´_ 4# jcchiang
§Úª¾¹D¤F,­n³o¼Ë§ï...·PÁ±z
.Range("C5").Resize(xcol, xcol).Value = ¬d±b_­qÁʼÆ
.Range("C5").Resize(xcol, xcol).Value = .Range("C5").Resize(xcol, xcol).Value

TOP

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