- ©«¤l
- 1447
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1471
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-12-5
|
¥Dnµ{¦¡½XÅܧó¦p¤U:
Option Explicit
Public Dats As Date, Datn As Date, AC_WO_NA
'¡ô³]¬°¥þ°ìÅܼÆ!µ¹¦U¹B¥Î¦¹°Æµ{¦¡ªº¥Dµ{¦¡¹B¥Î
Sub ªø§Ç¸¹Âà_¤é´Á_µu§Ç¸¹()
Dim Arr, i&, xB, N&, D1 As Date, TTT
'¡ô«Å§iÅܼÆ:D1 ¬O¤é´Á,N¬O¼Æ¦r
Set xB = Sheets("¥X³f¸ê®Æ")
'¡ô¥OxB¬O "¥X³f¸ê®Æ" ¤u§@ªí
Dats = 0
'¡ô°_©l¤éÂk¹s
Datn = 0
'¡ôµ²§ô¤éÂk¹s
If IsDate(xB.[I1]) Then
'¡ô¦pªG ¥X³f¸ê®Æªíªº[I1]¬O¤é´Á
Dats = xB.[I1]
'¡ô°_©l¤é´N¸Ë¤J³o¤é´Á
End If
If IsDate(xB.[J1]) Then
'¡ô¦pªG ¥X³f¸ê®Æªíªº[J1]¬O¤é´Á
Datn = xB.[J1]
'¡ôµ²§ô¤é´N¸Ë¤J³o¤é´Á
End If
Arr = xB.Range(xB.[J1], Cells(xB.UsedRange.EntireRow.Count, 1))
'¡ô¥OArr¬O"¥X³f¸ê®Æ" ¤u§@ªí A:GÄ椧¶¡¦³¨Ï¥Î¦Cªº°Ï°ìÀx¦s®æÈ
For i = 2 To UBound(Arr)
'¡ô³]°j°é©î¸ÑBÄ檺ªø§Ç¸¹
D1 = "20" & Mid(Arr(i, 2), 1, 2) & "/" & Mid(Arr(i, 2), 3, 2) & "/" & Mid(Arr(i, 2), 5, 2)
'¡ô "20",¥[ªø§Ç¸¹²Ä1Ó¦r¶}©l¨ú¨â¦r¤¸="22"
',¦A¥[ªø§Ç¸¹²Ä3Ó¦r¶}©l¨ú¨â¦r¤¸="10"
',¦A¥[ªø§Ç¸¹²Ä5Ó¦r¶}©l¨ú¨â¦r¤¸="08"
'D1="2022/10/08"¦r¦êÂà¤Æ¬°¤é´Á,¦]D1«Å§i¬°¤é´Á
Arr(i, 9) = D1
'¡ô§âD1¤é´Á©ñ¤JArrªº²Ä9Äæ¦ì¸m
N = Right(Arr(i, 2), 3)
'¡ô¥ON¬O±`§Ç¸¹ªº¥kÃä3Ó¦r¤¸¦r¦êÂà¼Æ¦r,¦]N«Å§i¬°¼Æ¦r
Arr(i, 10) = N
'¡ô§âN¼Æ¦r©ñ¤JArrªº²Ä10Äæ¦ì¸m
Next
Workbooks.Add
'¡ô¶}¤@Ó·sªºÀÉ®×
AC_WO_NA = ActiveWorkbook.Name
Sheets(1).Name = "¥X³f¸ê®Æ"
[A1].Resize(UBound(Arr), 10) = Arr
'¡ô§âArr°}¦Cªº¸ê®Æ±q[A1]¶}©lˤJ·s¤u§@ªíªº¦s®æ
If Datn = 0 Then
'¡ô¦pªGµ²§ô¤é¬OÂk¹sª¬ºA?
Datn = CDate(WorksheetFunction.Max([I:I]))
'¡ô±ø¥ó¦¨¥ß!´N§ì[I:I]¸Ìªº³Ì¤j¤é´Á¸Ë¶iµ²§ô¤é
End If
If Dats = 0 Then
'¡ô¦pªG°_©l¤é¬OÂk¹sª¬ºA?
Dats = CDate(WorksheetFunction.Min([I:I]))
'¡ô±ø¥ó¦¨¥ß!´N§ì[I:I]¸Ìªº³Ì¤p¤é´Á¸Ë¶i¶}©l¤é
End If
[I1] = "¥X³f¤é´Á"
[J1] = "·í¤é§Ç¸¹"
Cells.Columns.AutoFit
'¡ô¦Û°Ê½Õ¾ãÄæ¼e
Cells.Rows.AutoFit
'¡ô¦Û°Ê½Õ¾ã¦C°ª
[2:2].Select
ActiveWindow.FreezePanes = True
'¡ô²Ä¤G¦C¥H¤WÀx¦s®æáµ²µ¡®æ
[A1].Select
[A1].AutoFilter
'¡ô³]©w¿z¿ï
Cells.Borders.LineStyle = xlContinuous
'¡ôÅã¥Ü®æ½u
End Sub
Option Explicit
Sub «È¤á¥X³fª÷ÃB_²Îp¹Ïªí()
Application.ScreenUpdating = False
'¡ô°õ¦æ®É¿Ã¹õµe±¤£n¸òµÛÅÜ°Ê
Call ªø§Ç¸¹Âà_¤é´Á_µu§Ç¸¹
Dim Yrr, i&, xD, Arr, Brr, d, c, R
'¡ô«Å§iÅܼÆ
Set xD = CreateObject("Scripting.Dictionary")
'¡ô¥OxD¬O¦r¨å
Set Yrr = [¥X³f¸ê®Æ!A1].CurrentRegion
'¡ô¥O Yrr¬O [A1]¬Û¾F«DªÅ®æ©Ò¦ê³s°_¨ÓªºÀx¦s®æ,ÂX®i¨ì¤è¥¿°Ï°ìªº³Ì¤p½d³òÀx¦s®æ
c = [¥X³f¸ê®Æ!A1].End(xlToRight).Column
'¡ô¥OC¬O¦¹ªíªºÄæ¼Æ
R = [¥X³f¸ê®Æ!A1].End(xlDown).Row
'¡ô¥OR¬O¦¹ªíªº¦C¼Æ
For i = 2 To R
'¡ô³]°j°é±N«È¤á¦W§Q¥Î¦r¨å¥h°£«½Æ¨Ã²Ö¥[ GÄ檺ª÷ÃB
If Yrr(i, 9) < Dats Or Yrr(i, 9) > Datn Then
'¡ô¦pªG IÄæ¤é´Á¬O¤p©ó¶}©l¤é ©Î IÄæ¤é´Á¬O¤j©óµ²§ô¤é?
GoTo 999
'¡ô±ø¥ó¦¨¥ß!´N¸õ¨ì 999ªº¦ì¸mÄ~Äò°õ¦æ!
End If
If Yrr(i, 1) <> "" Then
d = Yrr(i, 1)
xD(d) = xD(d) + Yrr(i, 7)
End If
999
Next
Arr = Application.Transpose(xD.KEYS)
'¡ô¥OArr ¬O¦r¨åkeyÂà¸m¤§«áªº¤Gºû°}¦C
Brr = Application.Transpose(xD.Items)
'¡ô¥OBrr ¬O¦r¨åItemÂà¸m¤§«áªº¤Gºû°}¦C
Workbooks.Add
'¡ô¶}±Ò¤@Ó·sÀÉ®×
[A1] = "«È¤á"
[B1] = "¥X³fª÷ÃB²Îp(NT)/²Îp°Ï¶¡(" & Dats & "~" & Datn & ")"
'¡ô¹Ïªí¼ÐÃD¥[¤J¾ã²z¤é´Á°Ï¶¡
[A2].Resize(UBound(Arr), 1) = Arr
'¡ô±N Arr°}¦C±q[A2]¶K¤JÈ
[B2].Resize(UBound(Brr), 1) = Brr
'¡ô±N Brr°}¦C±q[B2]¶K¤JÈ
[A1].CurrentRegion.Sort _
KEY1:=[B1], Order1:=xlDescending, Header:=xlYes
'¡ô¸ê®Æ¦³©ïÀY¦Cªºº¥´î±Æ§Ç
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Range([A1], Cells([A65536].End(xlUp).Row, "B"))
With ActiveSheet.Shapes("¹Ïªí 1")
.ScaleWidth 1.5, msoFalse, msoScaleFromBottomRight
.ScaleWidth 1, msoFalse, msoScaleFromTopLeft
.ScaleHeight 1.5, msoFalse, msoScaleFromTopLeft
.IncrementLeft -500
.IncrementTop -500
End With
[A1].Activate
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlPieExploded
ActiveChart.SetSourceData Source:=Range([A1], Cells([A65536].End(xlUp).Row, "B"))
With ActiveSheet.Shapes("¹Ïªí 2")
.ScaleWidth 1.5, msoFalse, msoScaleFromBottomRight
.ScaleWidth 1, msoFalse, msoScaleFromTopLeft
.ScaleHeight 1.5, msoFalse, msoScaleFromTopLeft
.IncrementLeft -500
.IncrementTop -500
.IncrementTop 400
End With
ActiveSheet.ChartObjects("¹Ïªí 2").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).ApplyDataLabels
ActiveChart.SeriesCollection(1).DataLabels.Select
Selection.ShowPercentage = True
Selection.Position = xlLabelPositionOutsideEnd
'¡ô¿ý»s¥¨¶°´N¥i¥H²£¥Í³o¨âӹϪí!µø»Ý¨D½Õ¾ã!
[A1].Activate
Workbooks(AC_WO_NA).Close False
Set xD = Nothing
Set Arr = Nothing
Set Brr = Nothing
End Sub |
|