[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Macro to find odd due dates and move them

jln via OfficeKB.com

12/15/2006 2:57:00 PM

All dates are in column E but the data that i get has
9/1/2006
9/10/2006 odd due date this would be moved to column F.
and the due date in column E would be changed to 10/1/2006.
So on odd due dates we forward the date to the first day of the next month.
What i would like to do i create a macro that goes thought Colunm E and moves
all dates that are not the fist of the month to column F in the same row and
change the date in column E to the first of the next month.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programmin...

1 Answer

Nik

12/15/2006 3:16:00 PM

0

jln via OfficeKB.com wrote:
> All dates are in column E but the data that i get has
> 9/1/2006
> 9/10/2006 odd due date this would be moved to column F.
> and the due date in column E would be changed to 10/1/2006.
> So on odd due dates we forward the date to the first day of the next month.
> What i would like to do i create a macro that goes thought Colunm E and moves
> all dates that are not the fist of the month to column F in the same row and
> change the date in column E to the first of the next month.
>
You can use this:

Sub Nik_test()
For z = 1 To Sheet1.UsedRange.Rows.Count
With Sheet1
If Day(.Cells(z, 5)) <> 1 Then
.Cells(z, 6) = .Cells(z, 5)
.Cells(z, 5) = DateSerial(Year(.Cells(z, 6)), _
Month(.Cells(z, 5)) + 1, 1)

End If
End With
Next

End Sub

If you have a header row on your column, change the z=1 to... to z=2 to...

Nik