Good Morning Everyone,
I am working on a project which is hopefully leading to end soon. There are some codes which slows down the whole operation. I tried to identify those code and I found one of the code takes about a minute. The purpose of that code to clear the spaces that comes from database by exporting it to excel file, then putting 0 or * on those cells. I used several for each loop in that code.I am just wondering is there any way to run that code faster?
Thank you very much for the help.Here is my code
I am working on a project which is hopefully leading to end soon. There are some codes which slows down the whole operation. I tried to identify those code and I found one of the code takes about a minute. The purpose of that code to clear the spaces that comes from database by exporting it to excel file, then putting 0 or * on those cells. I used several for each loop in that code.I am just wondering is there any way to run that code faster?
Thank you very much for the help.Here is my code
Code:
Sub GivingBlankFigures_Swing()
Dim cel As Range
Dim LastRow As Long
LastRow = Sheets("SwingFloorMap").Range("A65536").End(xlUp).Row
For Each cel In Sheets("SwingFloorMap").Range("D2:K" & LastRow)
If cel = " " Then 'there are 9 spaces here
cel = 0
End If
If cel = "" Then
cel = "*"
End If
Next cel
For Each cel In Sheets("SwingFloorMap").Range("L2:L" & LastRow)
If cel = " " Then 'there are 9 spaces here
cel = 0
End If
If cel = "" Then
cel = 0
End If
Next cel
For Each cel In Sheets("SwingFloorMap").Range("M2:O" & LastRow)
If cel = " " Then 'there are 9 spaces here
cel = "*"
End If
If cel = "" Then
cel = "*"
End If
Next cel
For Each cel In Sheets("SwingFloorMap").Range("P2:P" & LastRow)
If cel = " " Then
cel = 0
End If
If cel = "" Then
cel = 0
End If
Next cel
For Each cel In Sheets("SwingFloorMap").Range("Q2:S" & LastRow)
If cel = " " Then
cel = "*"
End If
If cel = "" Then
cel = "*"
End If
Next cel
End Sub