Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default help with date comparision

Hello all

I had a sheet with a column (column 13) for dates. I am trying to write code that will take all the dates that are older than 120 days (from today) and move them to another sheet. This is what i have so far.. any help would be greatly appreciated

Sub ArchiveRoutine(

Dim iCt2 As Intege
Dim iRow3 As Intege
Dim iRow4 As Intege
Dim ws3 As Workshee
Dim ws4 As Workshee
Dim erow2 As Intege

Set ws3 = Sheets("Sheet2"
Set ws4 = Sheets("Sheet3"
iRow3 =
erow2 =
While ws4.Cells(erow, 13) < "": erow2 = erow2 + 1: Wen
iRow4 = erow

'copy from sheet2 to sheet
Do Until ws3.Cells(iRow3, 13) = "
If ws3.Cells(iRow3, 13) €“ ws3.DAYS360((TODAY()),B1,FALSE) 90 The
For iCt2 = 1 To 1
ws4.Cells(iRow4, iCt2) = ws3.Cells(iRow3, iCt2
Next iCt
iRow4 = iRow4 +
End I
iRow3 = iRow3 +
Loo

[Note: Below is another part I need to change completely I think. What I need to do is this: Remove the rows that were copied to sheet3 (ie. remove the duplicates)

'delete from sheet
For iCt2 = iRow3 To 2 Step -
If ws3.Cells(iRow3, 13) €“ ws3.DAYS360((TODAY()),B1,FALSE) 90 Then ws3.Rows(iCt2).Delet
Next iCt

End Su

I think I am doing the date comparison wrong€¦ I am not too familiar with VBA syntax.. Any ideas on how I would go about doing this?

Thank
Jay Baxte

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default tried another thing, subscript out of range

altered the code in my first message a bit. Still no luck. Now i get a subscript out of range error....hm

I dont know if my syntax with the dates (if then statements) are right.

please hel
-Jay Baxte

New Code
Sub ArchivedRoutine(

Dim iCt2 As Intege
Dim iRow3 As Intege
Dim iRow4 As Intege
Dim ws3 As Workshee
Dim ws4 As Workshee
Dim erow2 As Intege

Set ws3 = Sheets("Sheet2"
Set ws4 = Sheets("Sheet3"
iRow3 =
erow2 =
While ws4.Cells(erow2, 13) < "": erow2 = erow2 + 1: Wen
iRow4 = erow

'copy from sheet2 to sheet
Do Until ws3.Cells(iRow3, 13) = "
If DateValue(ws3.Cells(1, 2)) - DateValue(ws3.Cells(iRow3, 13)) 90 The
For iCt2 = 1 To 1
ws4.Cells(iRow4, iCt2) = ws3.Cells(iRow3, iCt2
Next iCt
iRow4 = iRow4 +
End I
iRow3 = iRow3 +
Loo

'delete from sheet
For iCt2 = iRow3 To 2 Step -
If DateValue(ws3.Cells(1, 2)) - DateValue(ws3.Cells(iRow3, 13)) 90 Then ws3.Rows(iCt2).Delet
Next iCt

End Sub
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
date comparision User Excel Discussion (Misc queries) 0 April 3rd 10 11:31 AM
dates comparision surya and siva[_2_] New Users to Excel 1 July 1st 09 05:39 PM
date range comparision on a criteria TUNGANA KURMA RAJU Excel Discussion (Misc queries) 0 April 20th 09 09:55 PM
vlookup for more than two comparision OPSHARMA Excel Discussion (Misc queries) 2 April 1st 09 03:29 PM
Date comparision Murray Excel Discussion (Misc queries) 3 September 8th 06 04:58 AM


All times are GMT +1. The time now is 09:04 PM.

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"