Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Loop and variable type

Hi! I have a loop in which I sometimes add to a variable. I check if a date
is a saturday, if yes then I check if it the day following that (ie the
sunday) is the last day of the month. if it is the last day of the month then
I add 1 to the variable datDate and if it is not the last day of the month
then I add 2. This works fine in the loop but once the code goes to the
MsgBox then datDate has the same value as before. Please help me solve this!
Thanks alot!

If Weekday(datDate) = 7 Then 'saturday
If Month(datDate) = Month(datDate + 1) Then
If Month(datDate + 1) < Month(datDate + 2) Then
datDate = datDate + 1 'jump to
sunday since last day of month
Else
datDate = datDate + 2 'jump to
monday
End If
End If
End If

MsgBox strDate


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Loop and variable type

hi Anne,

All of your checks & changes refer to datDate but the msgbox refers to
StrDate. does it work as expected if you change the last line from "MsgBox
strDate" to ""MsgBox datDate"?

hth
Rob


__________________
Rob Brockett
NZ
Always learning & the best way to learn is to experience...

"Arne Hegefors" wrote:

Hi! I have a loop in which I sometimes add to a variable. I check if a date
is a saturday, if yes then I check if it the day following that (ie the
sunday) is the last day of the month. if it is the last day of the month then
I add 1 to the variable datDate and if it is not the last day of the month
then I add 2. This works fine in the loop but once the code goes to the
MsgBox then datDate has the same value as before. Please help me solve this!
Thanks alot!

If Weekday(datDate) = 7 Then 'saturday
If Month(datDate) = Month(datDate + 1) Then
If Month(datDate + 1) < Month(datDate + 2) Then
datDate = datDate + 1 'jump to
sunday since last day of month
Else
datDate = datDate + 2 'jump to
monday
End If
End If
End If

MsgBox strDate


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop type formula - no Macro RD[_2_] Excel Discussion (Misc queries) 2 August 27th 09 02:02 AM
What type of loop? [email protected] Excel Programming 3 July 5th 07 07:55 PM
For Each ... Next loop - need to reference the loop variable [email protected] Excel Programming 4 July 13th 06 06:12 PM
Loop through a User-Defined Type? uf_gator Excel Programming 2 February 21st 06 06:57 PM
Type Error in For Each Worksheet Loop [email protected] Excel Programming 8 January 14th 06 05:37 PM


All times are GMT +1. The time now is 02:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"