For i=31 to 28 Step -1
sDateTo = iMonth &"/" & i & "/" &iYear
If IsDate(sDateTo) Then Exit For
Next
p/s Enjoy)
Nice one! I assume this is a "clever" way of determining how many days are in the given month/year ?
Actually, this piece of magic (mushroom) code calculates the last day of specified month (so its maybe 31 or 30 or 29 or 28)))))
Here is less magic but still working code :
sDateTo = DateAdd("m",1,firstDayOfMonth)-1
Day(DateSerial(y, m + 1, 0))
: IF` 0=GOTO` ALLOT-CELL ;: THEN` HERE SWAP ! ;: ELSE` GOTO` ALLOT-CELL SWAP THEN` ;