InaCell
Board Regular
- Joined
- Feb 2, 2010
- Messages
- 189
Hi
I have some code that works in 2 parts and is separated into 2 macros that are both called from a third.
The first macro selects the cells and clears the data within. These cells contain a formula which displays either TRUE or FALSE.
The second macro selects the cells and removes/clears the background colour if it exists.
Problem. The code is extremely slow. Could anyone improve the speed?
Thanks
I have some code that works in 2 parts and is separated into 2 macros that are both called from a third.
The first macro selects the cells and clears the data within. These cells contain a formula which displays either TRUE or FALSE.
The second macro selects the cells and removes/clears the background colour if it exists.
Problem. The code is extremely slow. Could anyone improve the speed?
Code:
Sub RemoveCode()
Application.ScreenUpdating = False ' speed up code for macro
Call RemoveTrueFalse
Call RemoveColour
Application.ScreenUpdating = True ' set back to normal
End Sub
Sub RemoveTrueFalse()
Dim x As Long, a As Long, b As Long
Application.ScreenUpdating = False ' speed up code for macro
Application.EnableEvents = False
For a = 3 To 27 Step 3 'selects columns C F I L O R U
x = Cells(Rows.Count, a).End(xlUp).Row ' sets last row of source range
For b = 7 To x 'source range starts at row 7 & goes to bottom
Cells(b, a).Value = "" 'remove all data from cell
Next b 'goes to next Row in source sheet
Next a 'goes to next Col in source sheet
Application.EnableEvents = True
Application.ScreenUpdating = True ' set back to normal
End Sub
Sub RemoveColour()
Dim x As Long, a As Long, b As Long
Application.ScreenUpdating = False ' speed up code for macro
Application.EnableEvents = False
For a = 1 To 25 Step 3 'selects columns A D G J M P S
x = Cells(Rows.Count, a).End(xlUp).Row ' sets last row of source range
For b = 7 To x 'source range starts at row 7 & goes to bottom
Cells(b, a).Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Next b 'goes to next Row in source sheet
Next a 'goes to next Col in source sheet
Application.EnableEvents = True
Application.ScreenUpdating = True ' set back to normal
End Sub
Thanks