简体   繁体   中英

Excel Macro - Very Slow

i want to make a macro that checks if the Date in Column A ist less then today. If so the macro should insert "done" in Column G.

Sub DoneCheck()

Dim rngZelle As Range, strText As String
With ActiveSheet

For Each c In Sheets("3. Umlagerungen").Range("A:A")
If c.Value < Int(Now) And Not (IsEmpty(c.Value)) Then c.Offset(0, 6).Value = "done"

Next c
End Sub

I know that it is very poorly coded but it works... The reason why I'm looking for help is because it runs really slow...

I tried it with Application.ScreenUpdating but it doesn't change anything.

Thank you in advance & greetings

You should only check the used cells in column A, and adding Application.ScreenUpdating = False always helps speed things up:

Sub DoneCheck()
Dim eRow as long

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

eRow = Thisworkbook.Sheets("3. Umlagerungen").Cells(Rows.Count,1).End(xlUp).Row

For Each c In Thisworkbook.Sheets("3. Umlagerungen").Range("A2:A" & eRow)
    If c.Value < Int(Now) And Not (IsEmpty(c.Value)) Then c.Offset(0, 6).Value = "done"
Next c

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM