PDA

View Full Version : Looping and shaking



achin
05-06-2008, 08:47 PM
HI.. I've wrote the source code below to compare values of column A and B.
It's run and perform as what I need it to be done.
But when I keyed in data in Column A and B.. and it give me the output too..but the screen of Excel sheet is shaking.. and it's obvioulsy looping for few seconds.
How to stop the shaking?

Besides, the when there's delays, it's displayed as: "Days Delayed-7"
I prefer to have Days "Delayed: 7"

Can anyone teach me how to do this?

p/S: input value of column A & B are in dates (dd.mm.yyyy)



Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
For Each Cell In Target
With Cell
If Cell = "" Then
Cells(.Row, "C").Value = ""
Else
If Cells(.Row, "A").Value > Cells(.Row, "B").Value Then
Cells(.Row, "C").Value = "On Time"
Else
Cells(.Row, "C").Value = "Days Delayed" & Cells(.Row, "A") - Cells(.Row, "B")
End If
End If
End With
Next Cell
End Sub

lucas
05-06-2008, 09:06 PM
Hi Achin, since you want to learn I think you should look up application.screenupdating in the vba help files to address the screen flicker.

As far as the colon why don't you just put it in behind the word Delayed? I may be missing something but as long as it is inside the quotation marks it should be returned in the cell....at least on my US version of Excel.....I think the hyphen you are using is serving as an operator and should be inside the quotation marks too....