- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
回復 2# cdkee - Option Explicit
- Sub Ex_Replace() '修改 :000 為 :00
- With ActiveSheet.Range("B:B,K:K")
- .Replace ":000", ":00", xlPart
- .NumberFormatLocal = "h:mm:ss;@"
- End With
- End Sub
- Sub Ex()
- Dim xi As Date, Ea, Rng(1 To 3) As Range
- On Error Resume Next
- Application.ScreenUpdating = False
- With Sheet1
- .AutoFilterMode = False
- Set Rng(1) = .Range("J1").CurrentRegion
- Set Rng(1) = .Range(Rng(1)(2, 1), Rng(1)(Rng(1).Rows.Count, Rng(1).Columns.Count))
- For xi = DateValue(.[J2]) To DateValue(.[J2].End(xlDown))
- For Each Ea In Array("9:16:00", "13:31:00")
- .AutoFilterMode = False
- .Range("J1").AutoFilter 1, Format(xi, "MM/DD/yYYY")
- .Range("J1").AutoFilter 2, Ea
- Set Rng(2) = Rng(1).SpecialCells(xlCellTypeVisible) '篩選不到資料 :有錯誤
- If Err.Number = 0 Then
- .AutoFilterMode = False
- Rng(2).Resize(2).Insert
- With Rng(2).Offset(-2).Resize(2)
- .Interior.ColorIndex = 6
- .Columns(1).Value = Rng(2).Cells(1)
- .Cells(1, 2) = Rng(2).Cells(2) - #12:02:00 AM#
- .Cells(2, 2) = Rng(2).Cells(2) - #12:01:00 AM#
- .Columns("C:F") = Rng(2).Cells(3).Value
- End With
- End If
- Next
- Next
- End With
- Application.ScreenUpdating = True
- End Sub
複製代碼 |
|