Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim m As Integer
Dim t As String
Dim w As String
Dim u As String
Dim Row1 As String
Dim Row2 As String
Dim Row3 As String
i = InputBox("請輸入要繪製圖表年分" & Chr(13) & "例如:105年輸入105", 繪製年份)
j = InputBox("請輸入要繪製圖表月分" & Chr(13) & "例如:1月輸入1", 繪製月份)
t = i & "." & j & "(工務所)"
w = i & "." & j & "(各項缺失統計圖)"
u = i & "." & j & "(權重統計分析)"
Sheets(t).Select
FindStr = "小計"
Set a = Cells.Find(FindStr, lookat:=xlWhole)
If a Is Nothing Then MsgBox "查無此字串" Else b = a.Address
If Len(b) = 5 Then Row = Right(b, 2) Else Row = Right(b, 1)
k = Row - 1
l = Row + 1
m = Row + 3
Row1 = "W" & CStr(k)
Row2 = "W" & CStr(l)
Row3 = "W" & CStr(m)
Charts.Add Before:=Worksheets(u)
ActiveChart.Name = w
Worksheets(t).Range("A3:" & Row1, "A" & l & ":" & Row2, "A" & m & ":" & Row3).Select