View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default Glitch in code some where, i think ?

are you sure you're not getting the values of E2 from 2 different sheets?

--


Gary


"Corey" wrote in message
...
I still get the code jumping from 31 October 2006 to 11 July 2006 for some
reason????

But i have another macro that displays a userform that also has displayed the
value in Cell E2,
and it Shows 7 November 2006, whereas the worksheet E2 value shows 11 July
2006.

Why ?
Corey....
"JLGWhiz" wrote in message
...
You might try it this way and see if it still does it. I basically put the
cell containing the date into a variable container and knocked out some
extraneous stuff. The key thing is using the variable container.

Sub callUpdates()
Sheets("Enter - Exit").Activate ' Sheet name
Dim ws As Worksheet, myDate As Date
myDate = Range("$E$2").Value
Application.ScreenUpdating = False
For Each ws In Application.Worksheets
ws.Activate
Range("E2") = myDate + 7
Next
Sheets("Enter - Exit").Activate
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

"Corey" wrote:

Have posted this eror before with no replies.

################################################## ###########
Sub callUpdates()
Sheets("Enter - Exit").Select ' Sheet name
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In Application.Worksheets
ws.Select
With Range("E2") ' Date value displayed a 31 October 2006
..Value = Range("E2").Value + 7 ' Should add 7 days to currently displayed
date value
End With
Next
Sheets("Enter - Exit").Select
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
################################################## ##########


The above code suppose to add 7 days to a date value in Cell E2,
Yet sometimes it works fine,
yet other times it jumps 6 months backwards from 31 October 2006 - 11 July
2006.


Why ?

Is there an error in the code?

Corey....