Date Elimination

I have a worksheet with mainly dates in column A in the format of '25 
Aug 2008'.  Is it possible with a macro or similar to delete lines 
beyond a certain date (2 years hence)?  Basically, I'm not interested in 
data more than 2 years old.

This would eliminate a lot of data and make for a more viewable worksheet.
0
9/26/2008 5:50:08 PM
excel 39879 articles. 2 followers. Follow

29 Replies
1003 Views

Similar Articles

[PageSpeed] 0

try this

Sub del_date()
ActiveCell.Range("A1").Select
Do Until ActiveCell.Value =3D ""
dt =3D Date - 730
If ActiveCell.Value <=3D dt Then
ActiveCell.ClearContents
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub

OR

in cell B1 put this formula and drag it
=3DIF(A1<TODAY()-DATE(2,1,0),"",A1)


On Sep 26, 1:50=A0pm, Saxman <john.h.williamsREMOVET...@btinternet.com>
wrote:
> I have a worksheet with mainly dates in column A in the format of '25
> Aug 2008'. =A0Is it possible with a macro or similar to delete lines
> beyond a certain date (2 years hence)? =A0Basically, I'm not interested i=
n
> data more than 2 years old.
>
> This would eliminate a lot of data and make for a more viewable worksheet=
..

0
muddanmadhu (119)
9/26/2008 6:45:43 PM
muddan madhu wrote:

> in cell B1 put this formula and drag it
> =IF(A1<TODAY()-DATE(2,1,0),"",A1)

Cannot get this to work.  It just copies the date from column A to column B.
0
9/26/2008 9:28:03 PM
muddan madhu wrote:
> try this
> 
> Sub del_date()
> ActiveCell.Range("A1").Select
> Do Until ActiveCell.Value = ""
> dt = Date - 730
> If ActiveCell.Value <= dt Then
> ActiveCell.ClearContents
> ActiveCell.Offset(1, 0).Select
> Else
> ActiveCell.Offset(1, 0).Select
> End If
> Loop
> End Sub

The above runs OK, but no lines are deleted.

Basically, if I had the following dates in column A:-

21 Aug 2008
5 Aug 2008
22 Jul 2008
2 Jul 2008
17 Jun 2008
22 May 2008
26 Nov 2007
15 Nov 2007
11 Nov 2007
1 Nov 2007
25 Oct 2007
18 Oct 2007
7 Oct 2007
7 Sep 2007
7 Aug 2007
16 Jun 2007
6 Sep 2006
11 Aug 2006
2 Aug 2006
4 Jul 2006
19 Jun 2006
4 Jun 2006
8 May 2006
24 Apr 2006
4 Apr 2006
20 Feb 2006
11 Feb 2006
29 Jun 2005
5 Jun 2005
17 May 2005
29 Apr 2005
5 Apr 2005
23 Mar 2005
22 Feb 2005
15 Jan 2005
18 Oct 2004
10 Oct 2004
27 Sep 2004
15 Sep 2004
27 Aug 2004
16 Aug 2004
5 Aug 2004
20 May 2004
30 Apr 2004
26 Nov 2003
1 Aug 2003

After running a macro to delete dates older than 1 year, I would like to 
see:-
21 Aug 2008
5 Aug 2008
22 Jul 2008
2 Jul 2008
17 Jun 2008
22 May 2008
26 Nov 2007
15 Nov 2007
11 Nov 2007
1 Nov 2007
25 Oct 2007
18 Oct 2007
7 Oct 2007

TIA
0
9/26/2008 9:37:48 PM
suppose in A1 u have date which is older than 2 year say 01-jun-06 ...
In B1 put the below formula u get blank cell,
If the date is not older than 2 year it will display the date ... once
that is done

use filter and in Col B - select blanks | delete the col A contents
then u will have date which is not older than 2  years.



On Sep 27, 2:28=A0am, Saxman <john.h.williamsREMOVET...@btinternet.com>
wrote:
> muddan madhu wrote:
> > in cell B1 put this formula and drag it
> > =3DIF(A1<TODAY()-DATE(2,1,0),"",A1)
>
> Cannot get this to work. =A0It just copies the date from column A to colu=
mn B.

0
muddanmadhu (119)
9/26/2008 9:41:45 PM
muddan madhu wrote:

>>> in cell B1 put this formula and drag it
>>> =IF(A1<TODAY()-DATE(2,1,0),"",A1)

This still returns dates older than 2 years/
0
9/26/2008 10:16:14 PM
The code works fine for me. It sound like your dates are not real dates but 
are text representations of dates.  Try re-formatting the *dates* as General 
and you should get a 5 digit number.  If it remaind looking loke the *date* 
then it is really just text.

-- 
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

sandymann2@mailinator.com
Replace @mailinator.com with @tiscali.co.uk


"Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
news:W5Wdnaor9OeEy0DVnZ2dneKdnZydnZ2d@bt.com...
> muddan madhu wrote:
>> try this
>>
>> Sub del_date()
>> ActiveCell.Range("A1").Select
>> Do Until ActiveCell.Value = ""
>> dt = Date - 730
>> If ActiveCell.Value <= dt Then
>> ActiveCell.ClearContents
>> ActiveCell.Offset(1, 0).Select
>> Else
>> ActiveCell.Offset(1, 0).Select
>> End If
>> Loop
>> End Sub
>
> The above runs OK, but no lines are deleted.
>
> Basically, if I had the following dates in column A:-
>
> 21 Aug 2008
> 5 Aug 2008
> 22 Jul 2008
> 2 Jul 2008
> 17 Jun 2008
> 22 May 2008
> 26 Nov 2007
> 15 Nov 2007
> 11 Nov 2007
> 1 Nov 2007
> 25 Oct 2007
> 18 Oct 2007
> 7 Oct 2007
> 7 Sep 2007
> 7 Aug 2007
> 16 Jun 2007
> 6 Sep 2006
> 11 Aug 2006
> 2 Aug 2006
> 4 Jul 2006
> 19 Jun 2006
> 4 Jun 2006
> 8 May 2006
> 24 Apr 2006
> 4 Apr 2006
> 20 Feb 2006
> 11 Feb 2006
> 29 Jun 2005
> 5 Jun 2005
> 17 May 2005
> 29 Apr 2005
> 5 Apr 2005
> 23 Mar 2005
> 22 Feb 2005
> 15 Jan 2005
> 18 Oct 2004
> 10 Oct 2004
> 27 Sep 2004
> 15 Sep 2004
> 27 Aug 2004
> 16 Aug 2004
> 5 Aug 2004
> 20 May 2004
> 30 Apr 2004
> 26 Nov 2003
> 1 Aug 2003
>
> After running a macro to delete dates older than 1 year, I would like to 
> see:-
> 21 Aug 2008
> 5 Aug 2008
> 22 Jul 2008
> 2 Jul 2008
> 17 Jun 2008
> 22 May 2008
> 26 Nov 2007
> 15 Nov 2007
> 11 Nov 2007
> 1 Nov 2007
> 25 Oct 2007
> 18 Oct 2007
> 7 Oct 2007
>
> TIA
> 


0
sandymann2 (1054)
9/26/2008 10:29:32 PM
Hi,

Maybe you could forget code and do it with AutoFilter.

Suppose your dates are in column A with the title in A1 and the first date 
in A2.  Place your cursor in the data and choose Data, Filter, Auto Filter.  
Next open the Date auto filter and choose Custom Filter.  On the left side 
pick Less than or equal to, on the right side enter the latest date you want 
ot remove, if you want it to be two year old data 9/26/06.  Click OK

Now you can select all the visible cells except the titles and delete them.

-- 
Thanks,
Shane Devenshire


"Saxman" wrote:

> I have a worksheet with mainly dates in column A in the format of '25 
> Aug 2008'.  Is it possible with a macro or similar to delete lines 
> beyond a certain date (2 years hence)?  Basically, I'm not interested in 
> data more than 2 years old.
> 
> This would eliminate a lot of data and make for a more viewable worksheet.
> 
0
9/27/2008 6:43:01 AM
Sandy Mann wrote:
> The code works fine for me. It sound like your dates are not real dates but 
> are text representations of dates.  Try re-formatting the *dates* as General 
> and you should get a 5 digit number.  If it remaind looking loke the *date* 
> then it is really just text.
> 
That could be the case.  They are imported from a web page and could 
well be formatted as text.  I try a workaround.
0
9/27/2008 11:36:10 AM
ShaneDevenshire wrote:

> Maybe you could forget code and do it with AutoFilter.
> 
> Suppose your dates are in column A with the title in A1 and the first date 
> in A2.  Place your cursor in the data and choose Data, Filter, Auto Filter.  
> Next open the Date auto filter and choose Custom Filter.  On the left side 
> pick Less than or equal to, on the right side enter the latest date you want 
> ot remove, if you want it to be two year old data 9/26/06.  Click OK
> 
> Now you can select all the visible cells except the titles and delete them.

My problem is that the dates are in 'blocks' under sub-headings.  If I 
sorted them all en-masse, it would mix the respective data.
0
9/27/2008 11:40:03 AM
Sandy Mann wrote:
> The code works fine for me. It sound like your dates are not real dates but 
> are text representations of dates.  Try re-formatting the *dates* as General 
> and you should get a 5 digit number.  If it remind looking like the *date* 
> then it is really just text.
> 

The dates are formatted as text on importation, but even if I format the 
column to date '10Mar 2004' (bottom of list in format cells), I still 
get a failure.

However, I have tried the code in another worksheet where I formatted 
the cells as text and typed them in manually and it works fine.  My 
problem is converting the text to dates.
0
9/27/2008 12:13:43 PM
The most common problem in downloading dates from the net is that they have 
non-breaking spaces, CHAR(160) attached to them.  Try, (on a copy of your 
data just in case), using the following formula in a helper column:

=--TRIM(SUBSTITUTE(C1,CHAR(160),""))

for a date in C1 and dragging down on the fill handle.  The copy and Paste 
Special back over the original data, (ie Cloumn C in thois case).

This should restore the dates to real dates but may need re-formatting to 
how you want them to look.

-- 
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

sandymann2@mailinator.com
Replace @mailinator.com with @tiscali.co.uk


"Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
news:8bSdnfpJYab8vkPVnZ2dnUVZ8u-dnZ2d@bt.com...
> Sandy Mann wrote:
>> The code works fine for me. It sound like your dates are not real dates 
>> but are text representations of dates.  Try re-formatting the *dates* as 
>> General and you should get a 5 digit number.  If it remind looking like 
>> the *date* then it is really just text.
>>
>
> The dates are formatted as text on importation, but even if I format the 
> column to date '10Mar 2004' (bottom of list in format cells), I still get 
> a failure.
>
> However, I have tried the code in another worksheet where I formatted the 
> cells as text and typed them in manually and it works fine.  My problem is 
> converting the text to dates.
> 


0
sandymann2 (1054)
9/27/2008 5:38:04 PM
Sandy Mann wrote:
> The most common problem in downloading dates from the net is that they have 
> non-breaking spaces, CHAR(160) attached to them.  Try, (on a copy of your 
> data just in case), using the following formula in a helper column:
> 
> =--TRIM(SUBSTITUTE(C1,CHAR(160),""))
> 
> for a date in C1 and dragging down on the fill handle.  The copy and Paste 
> Special back over the original data, (ie Cloumn C in thois case).
> 
> This should restore the dates to real dates but may need re-formatting to 
> how you want them to look.
> 

Thanks.  I will try it in the morning.
0
9/28/2008 12:52:51 AM
Sandy Mann wrote:
> The most common problem in downloading dates from the net is that they have 
> non-breaking spaces, CHAR(160) attached to them.  Try, (on a copy of your 
> data just in case), using the following formula in a helper column:
> 
> =--TRIM(SUBSTITUTE(C1,CHAR(160),""))
> 
> for a date in C1 and dragging down on the fill handle.  The copy and Paste 
> Special back over the original data, (ie Column C in this case).
> 
> This should restore the dates to real dates but may need re-formatting to 
> how you want them to look.
> 

The above works fine if the cells are pre-formatted to date.  However, I 
cannot get the following code kindly provided by Muddan Madhu to work on 
anything but freshly entered data?

Sub del_date()
ActiveCell.Range("A1").Select
Do Until ActiveCell.Value = ""
dt = Date - 730
If ActiveCell.Value <= dt Then
ActiveCell.ClearContents
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub
0
9/28/2008 1:38:31 PM
"Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
news:F9adnbu0GZ1dFULVnZ2dneKdnZydnZ2d@bt.com...
> The above works fine if the cells are pre-formatted to date.  However, I 
> cannot get the following code kindly provided by Muddan Madhu to work on 
> anything but freshly entered data?

That will be because the original data is text and needs converting to real 
dates.  Adding:

ActiveCell.Value = Trim(Application.Substitute(Selection.Value, Chr(160), 
""))

after the *Do* line in Saxman's code will allow it to work - but note that 
the first line: ActiveCell.Range("A1").Select means that A1 must be the 
active cell  before the code is run.

It is not necessary to select a cell to work on it so, depending on the 
layout of your data this may also work:

Option Explicit
Sub DeleteDate()
    Dim LastRow As Long
    Dim dt As Date
    Dim cell As Range
    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    dt = Date - 730
    For Each cell In Range(Cells(1, 1), Cells(LastRow, 1))
        cell.Value = _
            Trim(Application.Substitute(cell.Value, _
                Chr(160), ""))
        If IsDate(cell.Value) Then
            cell.NumberFormat = "d mmm yyyy"
                If cell.Value < dt Then cell.ClearContents
        End If
    Next cell
End Sub


-- 
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

sandymann2@mailinator.com
Replace @mailinator.com with @tiscali.co.uk


"Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
news:F9adnbu0GZ1dFULVnZ2dneKdnZydnZ2d@bt.com...
> Sandy Mann wrote:
>> The most common problem in downloading dates from the net is that they 
>> have non-breaking spaces, CHAR(160) attached to them.  Try, (on a copy of 
>> your data just in case), using the following formula in a helper column:
>>
>> =--TRIM(SUBSTITUTE(C1,CHAR(160),""))
>>
>> for a date in C1 and dragging down on the fill handle.  The copy and 
>> Paste Special back over the original data, (ie Column C in this case).
>>
>> This should restore the dates to real dates but may need re-formatting to 
>> how you want them to look.
>>
>
> The above works fine if the cells are pre-formatted to date.  However, I 
> cannot get the following code kindly provided by Muddan Madhu to work on 
> anything but freshly entered data?
>
> Sub del_date()
> ActiveCell.Range("A1").Select
> Do Until ActiveCell.Value = ""
> dt = Date - 730
> If ActiveCell.Value <= dt Then
> ActiveCell.ClearContents
> ActiveCell.Offset(1, 0).Select
> Else
> ActiveCell.Offset(1, 0).Select
> End If
> Loop
> End Sub
> 


0
sandymann2 (1054)
9/28/2008 5:32:54 PM
Sandy Mann wrote:

> Option Explicit
> Sub DeleteDate()
>     Dim LastRow As Long
>     Dim dt As Date
>     Dim cell As Range
>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>     dt = Date - 730
>     For Each cell In Range(Cells(1, 1), Cells(LastRow, 1))
>         cell.Value = _
>             Trim(Application.Substitute(cell.Value, _
>                 Chr(160), ""))
>         If IsDate(cell.Value) Then
>             cell.NumberFormat = "d mmm yyyy"
>                 If cell.Value < dt Then cell.ClearContents
>         End If
>     Next cell
> End Sub
> 

I will give it a go Monday Sandy.

Thanks.
0
9/28/2008 8:19:38 PM
Sandy Mann wrote:

> Option Explicit
> Sub DeleteDate()
>     Dim LastRow As Long
>     Dim dt As Date
>     Dim cell As Range
>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>     dt = Date - 730
>     For Each cell In Range(Cells(1, 1), Cells(LastRow, 1))
>         cell.Value = _
>             Trim(Application.Substitute(cell.Value, _
>                 Chr(160), ""))
>         If IsDate(cell.Value) Then
>             cell.NumberFormat = "d mmm yyyy"
>                 If cell.Value < dt Then cell.ClearContents
>         End If
>     Next cell
> End Sub

This works a treat!  Thanks.

Now phase 2 :-)
With empty cells in column A, can a piece of coding delete the lines 
with empty cells in column A and can it be added to the above code?
0
9/29/2008 6:22:30 PM
"Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
news:JpqdnQAvZpF-gXzVnZ2dnUVZ8tLinZ2d@bt.com...
> Now phase 2 :-)
> With empty cells in column A, can a piece of coding delete the lines with 
> empty cells in column A and can it be added to the above code?
>
If you are going to delete the rows then there is no need to clear the cells 
first.  Also to delete rows you have to work from the bottom up otherwise 
the count will go wrong.  This will delete all rows with dates older than 
730 days ago:

Option Explicit
Sub DeleteDate()
    Dim LastRow As Long
    Dim dt As Date
    Dim Counter As Long
    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    dt = Date - 730
    Application.ScreenUpdating = False
    For Counter = LastRow To 1 Step -1
        Cells(Counter, 1).Value = _
            Trim(Application.Substitute(Cells(Counter, 1).Value, _
                Chr(160), ""))
        If IsDate(Cells(Counter, 1).Value) Then
                If Cells(Counter, 1).Value < dt Then _
                    Cells(Counter, 1).EntireRow.Delete
        End If
    Next Counter
    Application.ScreenUpdating = True
End Sub

-- 
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

sandymann2@mailinator.com
Replace @mailinator.com with @tiscali.co.uk


0
sandymann2 (1054)
9/29/2008 6:48:48 PM
Sandy Mann wrote:

> If you are going to delete the rows then there is no need to clear the cells 
> first.  Also to delete rows you have to work from the bottom up otherwise 
> the count will go wrong.  This will delete all rows with dates older than 
> 730 days ago:
> 
> Option Explicit
> Sub DeleteDate()
>     Dim LastRow As Long
>     Dim dt As Date
>     Dim Counter As Long
>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>     dt = Date - 730
>     Application.ScreenUpdating = False
>     For Counter = LastRow To 1 Step -1
>         Cells(Counter, 1).Value = _
>             Trim(Application.Substitute(Cells(Counter, 1).Value, _
>                 Chr(160), ""))
>         If IsDate(Cells(Counter, 1).Value) Then
>                 If Cells(Counter, 1).Value < dt Then _
>                     Cells(Counter, 1).EntireRow.Delete
>         End If
>     Next Counter
>     Application.ScreenUpdating = True
> End Sub
> 

This works perfectly Sandy.  I'm very grateful to you.

I was in the Bon Accord, North Street, Glasgow very recently.  If you 
were there, I would have bought you a drink!
0
9/29/2008 8:49:12 PM
You are very welcome, glad to have been of help

-- 
Regards,

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

sandymann2@mailinator.com
Replace @mailinator.com with @tiscali.co.uk


"Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
news:MbKdnXMh6oHZonzVnZ2dneKdnZydnZ2d@bt.com...
> Sandy Mann wrote:
>
>> If you are going to delete the rows then there is no need to clear the 
>> cells first.  Also to delete rows you have to work from the bottom up 
>> otherwise the count will go wrong.  This will delete all rows with dates 
>> older than 730 days ago:
>>
>> Option Explicit
>> Sub DeleteDate()
>>     Dim LastRow As Long
>>     Dim dt As Date
>>     Dim Counter As Long
>>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>>     dt = Date - 730
>>     Application.ScreenUpdating = False
>>     For Counter = LastRow To 1 Step -1
>>         Cells(Counter, 1).Value = _
>>             Trim(Application.Substitute(Cells(Counter, 1).Value, _
>>                 Chr(160), ""))
>>         If IsDate(Cells(Counter, 1).Value) Then
>>                 If Cells(Counter, 1).Value < dt Then _
>>                     Cells(Counter, 1).EntireRow.Delete
>>         End If
>>     Next Counter
>>     Application.ScreenUpdating = True
>> End Sub
>>
>
> This works perfectly Sandy.  I'm very grateful to you.
>
> I was in the Bon Accord, North Street, Glasgow very recently.  If you were 
> there, I would have bought you a drink!
> 


0
sandymann2 (1054)
9/29/2008 9:35:42 PM
Sandy Mann wrote:

> It is not necessary to select a cell to work on it so, depending on the 
> layout of your data this may also work:
> 
> Option Explicit
> Sub DeleteDate()
>     Dim LastRow As Long
>     Dim dt As Date
>     Dim cell As Range
>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>     dt = Date - 730
>     For Each cell In Range(Cells(1, 1), Cells(LastRow, 1))
>         cell.Value = _
>             Trim(Application.Substitute(cell.Value, _
>                 Chr(160), ""))
>         If IsDate(cell.Value) Then
>             cell.NumberFormat = "d mmm yyyy"
>                 If cell.Value < dt Then cell.ClearContents
>         End If
>     Next cell
> End Sub

Just one more thing.  A few blank cells remaining in column A after 
running the above code (lines with no data).  Could I select these empty 
cells and delete the corresponding lines and possibly include it in the 
above code?
0
9/30/2008 8:21:34 PM
"Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
news:vqOdnQex5aXaF3_VRVnyhAA@bt.com...
> Just one more thing.  A few blank cells remaining in column A after 
> running the above code (lines with no data).  Could I select these empty 
> cells and delete the corresponding lines and possibly include it in the 
> above code?

No, not with that code, if you try to delete rows going down the sheet the 
count of rows will go wrong because if you delete Row 10 for example, Row 
11, which may be a Row that should be deleted, will immediately become the 
new Row 10 and the code will index up to Row 11 so the *old* Row 11 which is 
now Row 10, will not get deleted.

Try this code which is a modification of the last code that I posted.

Option Explicit
Sub DeleteDate()
    Dim LastRow As Long
    Dim dt As Date
    Dim Counter As Long

    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    dt = Date - 730
    Application.ScreenUpdating = False

    For Counter = LastRow To 1 Step -1
        Cells(Counter, 1).Value = _
            Trim(Application.Substitute(Cells(Counter, 1).Value, _
                Chr(160), ""))

        If IsDate(Cells(Counter, 1).Value) Then
                If Cells(Counter, 1).Value < dt Then _
                        Cells(Counter, 1).EntireRow.Delete
        End If

        If Cells(Counter, 1).Value = "" Then _
            Cells(Counter, 1).EntireRow.Delete

    Next Counter
    Application.ScreenUpdating = True
End Sub



-- 
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

sandymann2@mailinator.com
Replace @mailinator.com with @tiscali.co.uk


"Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
news:vqOdnQex5aXaF3_VRVnyhAA@bt.com...
> Sandy Mann wrote:
>
>> It is not necessary to select a cell to work on it so, depending on the 
>> layout of your data this may also work:
>>
>> Option Explicit
>> Sub DeleteDate()
>>     Dim LastRow As Long
>>     Dim dt As Date
>>     Dim cell As Range
>>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>>     dt = Date - 730
>>     For Each cell In Range(Cells(1, 1), Cells(LastRow, 1))
>>         cell.Value = _
>>             Trim(Application.Substitute(cell.Value, _
>>                 Chr(160), ""))
>>         If IsDate(cell.Value) Then
>>             cell.NumberFormat = "d mmm yyyy"
>>                 If cell.Value < dt Then cell.ClearContents
>>         End If
>>     Next cell
>> End Sub
>
> Just one more thing.  A few blank cells remaining in column A after 
> running the above code (lines with no data).  Could I select these empty 
> cells and delete the corresponding lines and possibly include it in the 
> above code?
> 


0
sandymann2 (1054)
9/30/2008 9:09:30 PM
Hi John,

Sometimes I sits and thinks and sometimes I just sits.

Of course it is possible to delete the rows with the code that you posted. 
Try this code:

Option Explicit
Sub DeleteDate2()
    Dim LastRow As Long
    Dim dt As Date
    Dim cell As Range
    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    dt = Date - 730
    For Each cell In Range(Cells(1, 1), Cells(LastRow, 1))
        cell.Value = _
            Trim(Application.Substitute(cell.Value, _
                Chr(160), ""))
        If IsDate(cell.Value) Then
            cell.NumberFormat = "d mmm yyyy"
                If cell.Value < dt Then cell.ClearContents
        End If
    Next cell

    LastRow = Cells(Rows.Count, 1).End(xlUp).Row

    On Error Resume Next
        Range(Cells(1, 1), Cells(LastRow, 1)) _
            .SpecialCells(xlCellTypeBlanks) _
                .EntireRow.Delete
    On Error GoTo 0
End Sub

As always try it on a copy of your data first.

-- 
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

sandymann2@mailinator.com
Replace @mailinator.com with @tiscali.co.uk


"Sandy Mann" <sandymann2@mailinator.com> wrote in message 
news:uUeeUD0IJHA.2580@TK2MSFTNGP05.phx.gbl...
> "Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
> news:vqOdnQex5aXaF3_VRVnyhAA@bt.com...
>> Just one more thing.  A few blank cells remaining in column A after 
>> running the above code (lines with no data).  Could I select these empty 
>> cells and delete the corresponding lines and possibly include it in the 
>> above code?
>
> No, not with that code, if you try to delete rows going down the sheet the 
> count of rows will go wrong because if you delete Row 10 for example, Row 
> 11, which may be a Row that should be deleted, will immediately become the 
> new Row 10 and the code will index up to Row 11 so the *old* Row 11 which 
> is now Row 10, will not get deleted.
>
> Try this code which is a modification of the last code that I posted.
>
> Option Explicit
> Sub DeleteDate()
>    Dim LastRow As Long
>    Dim dt As Date
>    Dim Counter As Long
>
>    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>    dt = Date - 730
>    Application.ScreenUpdating = False
>
>    For Counter = LastRow To 1 Step -1
>        Cells(Counter, 1).Value = _
>            Trim(Application.Substitute(Cells(Counter, 1).Value, _
>                Chr(160), ""))
>
>        If IsDate(Cells(Counter, 1).Value) Then
>                If Cells(Counter, 1).Value < dt Then _
>                        Cells(Counter, 1).EntireRow.Delete
>        End If
>
>        If Cells(Counter, 1).Value = "" Then _
>            Cells(Counter, 1).EntireRow.Delete
>
>    Next Counter
>    Application.ScreenUpdating = True
> End Sub
>
>
>
> -- 
> HTH
>
> Sandy
> In Perth, the ancient capital of Scotland
> and the crowning place of kings
>
> sandymann2@mailinator.com
> Replace @mailinator.com with @tiscali.co.uk
>
>
> "Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
> news:vqOdnQex5aXaF3_VRVnyhAA@bt.com...
>> Sandy Mann wrote:
>>
>>> It is not necessary to select a cell to work on it so, depending on the 
>>> layout of your data this may also work:
>>>
>>> Option Explicit
>>> Sub DeleteDate()
>>>     Dim LastRow As Long
>>>     Dim dt As Date
>>>     Dim cell As Range
>>>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>>>     dt = Date - 730
>>>     For Each cell In Range(Cells(1, 1), Cells(LastRow, 1))
>>>         cell.Value = _
>>>             Trim(Application.Substitute(cell.Value, _
>>>                 Chr(160), ""))
>>>         If IsDate(cell.Value) Then
>>>             cell.NumberFormat = "d mmm yyyy"
>>>                 If cell.Value < dt Then cell.ClearContents
>>>         End If
>>>     Next cell
>>> End Sub
>>
>> Just one more thing.  A few blank cells remaining in column A after 
>> running the above code (lines with no data).  Could I select these empty 
>> cells and delete the corresponding lines and possibly include it in the 
>> above code?
>>
>
>
> 


0
sandymann2 (1054)
9/30/2008 9:29:25 PM
Additionally, if you have a large amount of data it would be as well to 
include turning the screenupdating off:

Option Explicit
Sub DeleteDate3()
    Dim LastRow As Long
    Dim dt As Date
    Dim cell As Range
    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    dt = Date - 730
    Application.ScreenUpdating = False
    For Each cell In Range(Cells(1, 1), Cells(LastRow, 1))
        cell.Value = _
            Trim(Application.Substitute(cell.Value, _
                Chr(160), ""))
        If IsDate(cell.Value) Then
            cell.NumberFormat = "d mmm yyyy"
                If cell.Value < dt Then cell.ClearContents
        End If
    Next cell

    LastRow = Cells(Rows.Count, 1).End(xlUp).Row

    On Error Resume Next
        Range(Cells(1, 1), Cells(LastRow, 1)) _
            .SpecialCells(xlCellTypeBlanks) _
                .EntireRow.Delete
    On Error GoTo 0
    Application.ScreenUpdating = True
End Sub

-- 
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

sandymann2@mailinator.com
Replace @mailinator.com with @tiscali.co.uk


"Sandy Mann" <sandymann2@mailinator.com> wrote in message 
news:%231PudO0IJHA.2580@TK2MSFTNGP05.phx.gbl...
> Hi John,
>
> Sometimes I sits and thinks and sometimes I just sits.
>
> Of course it is possible to delete the rows with the code that you posted. 
> Try this code:
>
> Option Explicit
> Sub DeleteDate2()
>    Dim LastRow As Long
>    Dim dt As Date
>    Dim cell As Range
>    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>    dt = Date - 730
>    For Each cell In Range(Cells(1, 1), Cells(LastRow, 1))
>        cell.Value = _
>            Trim(Application.Substitute(cell.Value, _
>                Chr(160), ""))
>        If IsDate(cell.Value) Then
>            cell.NumberFormat = "d mmm yyyy"
>                If cell.Value < dt Then cell.ClearContents
>        End If
>    Next cell
>
>    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>
>    On Error Resume Next
>        Range(Cells(1, 1), Cells(LastRow, 1)) _
>            .SpecialCells(xlCellTypeBlanks) _
>                .EntireRow.Delete
>    On Error GoTo 0
> End Sub
>
> As always try it on a copy of your data first.
>
> -- 
> HTH
>
> Sandy
> In Perth, the ancient capital of Scotland
> and the crowning place of kings
>
> sandymann2@mailinator.com
> Replace @mailinator.com with @tiscali.co.uk
>
>
> "Sandy Mann" <sandymann2@mailinator.com> wrote in message 
> news:uUeeUD0IJHA.2580@TK2MSFTNGP05.phx.gbl...
>> "Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
>> news:vqOdnQex5aXaF3_VRVnyhAA@bt.com...
>>> Just one more thing.  A few blank cells remaining in column A after 
>>> running the above code (lines with no data).  Could I select these empty 
>>> cells and delete the corresponding lines and possibly include it in the 
>>> above code?
>>
>> No, not with that code, if you try to delete rows going down the sheet 
>> the count of rows will go wrong because if you delete Row 10 for example, 
>> Row 11, which may be a Row that should be deleted, will immediately 
>> become the new Row 10 and the code will index up to Row 11 so the *old* 
>> Row 11 which is now Row 10, will not get deleted.
>>
>> Try this code which is a modification of the last code that I posted.
>>
>> Option Explicit
>> Sub DeleteDate()
>>    Dim LastRow As Long
>>    Dim dt As Date
>>    Dim Counter As Long
>>
>>    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>>    dt = Date - 730
>>    Application.ScreenUpdating = False
>>
>>    For Counter = LastRow To 1 Step -1
>>        Cells(Counter, 1).Value = _
>>            Trim(Application.Substitute(Cells(Counter, 1).Value, _
>>                Chr(160), ""))
>>
>>        If IsDate(Cells(Counter, 1).Value) Then
>>                If Cells(Counter, 1).Value < dt Then _
>>                        Cells(Counter, 1).EntireRow.Delete
>>        End If
>>
>>        If Cells(Counter, 1).Value = "" Then _
>>            Cells(Counter, 1).EntireRow.Delete
>>
>>    Next Counter
>>    Application.ScreenUpdating = True
>> End Sub
>>
>>
>>
>> -- 
>> HTH
>>
>> Sandy
>> In Perth, the ancient capital of Scotland
>> and the crowning place of kings
>>
>> sandymann2@mailinator.com
>> Replace @mailinator.com with @tiscali.co.uk
>>
>>
>> "Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
>> news:vqOdnQex5aXaF3_VRVnyhAA@bt.com...
>>> Sandy Mann wrote:
>>>
>>>> It is not necessary to select a cell to work on it so, depending on the 
>>>> layout of your data this may also work:
>>>>
>>>> Option Explicit
>>>> Sub DeleteDate()
>>>>     Dim LastRow As Long
>>>>     Dim dt As Date
>>>>     Dim cell As Range
>>>>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>>>>     dt = Date - 730
>>>>     For Each cell In Range(Cells(1, 1), Cells(LastRow, 1))
>>>>         cell.Value = _
>>>>             Trim(Application.Substitute(cell.Value, _
>>>>                 Chr(160), ""))
>>>>         If IsDate(cell.Value) Then
>>>>             cell.NumberFormat = "d mmm yyyy"
>>>>                 If cell.Value < dt Then cell.ClearContents
>>>>         End If
>>>>     Next cell
>>>> End Sub
>>>
>>> Just one more thing.  A few blank cells remaining in column A after 
>>> running the above code (lines with no data).  Could I select these empty 
>>> cells and delete the corresponding lines and possibly include it in the 
>>> above code?
>>>
>>
>>
>>
>
>
> 


0
sandymann2 (1054)
9/30/2008 9:35:39 PM
Sandy Mann wrote:

> Try this code which is a modification of the last code that I posted.
> 
> Option Explicit
> Sub DeleteDate()
>     Dim LastRow As Long
>     Dim dt As Date
>     Dim Counter As Long
> 
>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>     dt = Date - 730
>     Application.ScreenUpdating = False
> 
>     For Counter = LastRow To 1 Step -1
>         Cells(Counter, 1).Value = _
>             Trim(Application.Substitute(Cells(Counter, 1).Value, _
>                 Chr(160), ""))
> 
>         If IsDate(Cells(Counter, 1).Value) Then
>                 If Cells(Counter, 1).Value < dt Then _
>                         Cells(Counter, 1).EntireRow.Delete
>         End If
> 
>         If Cells(Counter, 1).Value = "" Then _
>             Cells(Counter, 1).EntireRow.Delete
> 
>     Next Counter
>     Application.ScreenUpdating = True
> End Sub

The above deletes the empty cells and their lines (as requested in my 
last posting), but still leaves all dates intact.
0
9/30/2008 9:36:03 PM
Sandy Mann wrote:

> Of course it is possible to delete the rows with the code that you posted. 
> Try this code:
> 
> Option Explicit
> Sub DeleteDate2()
>     Dim LastRow As Long
>     Dim dt As Date
>     Dim cell As Range
>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>     dt = Date - 730
>     For Each cell In Range(Cells(1, 1), Cells(LastRow, 1))
>         cell.Value = _
>             Trim(Application.Substitute(cell.Value, _
>                 Chr(160), ""))
>         If IsDate(cell.Value) Then
>             cell.NumberFormat = "d mmm yyyy"
>                 If cell.Value < dt Then cell.ClearContents
>         End If
>     Next cell
> 
>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
> 
>     On Error Resume Next
>         Range(Cells(1, 1), Cells(LastRow, 1)) _
>             .SpecialCells(xlCellTypeBlanks) _
>                 .EntireRow.Delete
>     On Error GoTo 0
> End Sub

This does not get rid of the empty cells + lines, just the requested 
dates in excess of 730.
0
9/30/2008 9:47:15 PM
Sandy Mann wrote:
> Additionally, if you have a large amount of data it would be as well to 
> include turning the screenupdating off:
> 
> Option Explicit
> Sub DeleteDate3()
>     Dim LastRow As Long
>     Dim dt As Date
>     Dim cell As Range
>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>     dt = Date - 730
>     Application.ScreenUpdating = False
>     For Each cell In Range(Cells(1, 1), Cells(LastRow, 1))
>         cell.Value = _
>             Trim(Application.Substitute(cell.Value, _
>                 Chr(160), ""))
>         If IsDate(cell.Value) Then
>             cell.NumberFormat = "d mmm yyyy"
>                 If cell.Value < dt Then cell.ClearContents
>         End If
>     Next cell
> 
>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
> 
>     On Error Resume Next
>         Range(Cells(1, 1), Cells(LastRow, 1)) _
>             .SpecialCells(xlCellTypeBlanks) _
>                 .EntireRow.Delete
>     On Error GoTo 0
>     Application.ScreenUpdating = True
> End Sub
> 

This deletes the dates and 'some' empty cells + respective lines.  I 
guess it's rather difficult without seeing the data.

Below is an example of what column A looks like.  The code was set to 
365 days, so no dates beyond that period appear which is what I require.

I'm not about Wednesday, but will look Thursday am if you have posted 
anything.

No. 1   CHJIMES
4 Year-old Gelding    Trainer - C DORE    Jockey - T EAVES
Date
14 Sep 2008
28 Aug 2008
12 Aug 2008
23 Jul 2008
14 Jul 2008
9 Jul 2008
23 Jun 2008
18 Jun 2008
9 May 2008
26 Apr 2008
12 Apr 2008
26 Mar 2008
5 Mar 2008
15 Feb 2008
4 Feb 2008
30 Jan 2008
27 Oct 2007
14 Oct 2007



No. 2   KEEL
5 Year-old Gelding    Trainer - C DORE    Jockey - LIAM JONES
Date
20 Jul 2008
12 Jul 2008
5 Jul 2008



No. 3   FOOLS GOLD
3 Year-old Gelding    Trainer - G D BLAKE    Jockey - PAUL EDDERY
Date
4 Aug 2008
9 Jul 2008
10 Jun 2008
3 Jun 2008
3 Apr 2008
11 Mar 2008
14 Dec 2007
12 Oct 2007



No. 4   DAN CHILLINGWORTH
3 Year-old Colt    Trainer - J FANSHAWE    Jockey - R WINSTON
Date
6 Sep 2008
25 Aug 2008
13 Aug 2008
28 Jul 2008
10 Jul 2008
31 May 2008
29 Oct 2007



No. 5   PRIME FACTOR
3 Year-old Gelding    Trainer - B HILLS    Jockey - C CATLIN
Date
6 Sep 2008
25 Aug 2008
9 Aug 2008
3 Jul 2008
11 Jun 2008
29 May 2008
29 Feb 2008
10 Feb 2008
16 Jan 2008



No. 6   SUN CATCHER
5 Year-old Gelding    Trainer - P G MURPHY    Jockey - S DROWNE
Date
10 Sep 2008
25 Jul 2008
2 Jul 2008
29 May 2008
20 May 2008
14 May 2008
4 May 2008
8 Apr 2008
27 Mar 2008
15 Mar 2008
23 Oct 2007

0
9/30/2008 9:58:11 PM
Hi John,

> This does not get rid of the empty cells + lines, just the requested dates 
> in excess of 730.

mmmmm..... It does for me whether the cells are truly blank or a formula 
returning an empty string. Can you send me a sample workbook, (sanitised of 
sensitive data if necessary), for me to test?
Replace the part after the @ sign as it says in my signature.


-- 
Regards,


Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

sandymann2@mailinator.com
Replace @mailinator.com with @tiscali.co.uk


"Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
news:ko2dnYWH1LbGA3_VnZ2dneKdnZydnZ2d@bt.com...
> Sandy Mann wrote:
>
>> Of course it is possible to delete the rows with the code that you 
>> posted. Try this code:
>>
>> Option Explicit
>> Sub DeleteDate2()
>>     Dim LastRow As Long
>>     Dim dt As Date
>>     Dim cell As Range
>>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>>     dt = Date - 730
>>     For Each cell In Range(Cells(1, 1), Cells(LastRow, 1))
>>         cell.Value = _
>>             Trim(Application.Substitute(cell.Value, _
>>                 Chr(160), ""))
>>         If IsDate(cell.Value) Then
>>             cell.NumberFormat = "d mmm yyyy"
>>                 If cell.Value < dt Then cell.ClearContents
>>         End If
>>     Next cell
>>
>>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>>
>>     On Error Resume Next
>>         Range(Cells(1, 1), Cells(LastRow, 1)) _
>>             .SpecialCells(xlCellTypeBlanks) _
>>                 .EntireRow.Delete
>>     On Error GoTo 0
>> End Sub
>
> This does not get rid of the empty cells + lines, just the requested dates 
> in excess of 730.
> 


0
sandymann2 (1054)
9/30/2008 10:07:01 PM
"Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
news:UbadnetUYs1xPX_VnZ2dnUVZ8j6dnZ2d@bt.com...
> This deletes the dates and 'some' empty cells + respective lines.

If it deletes *some* rows then there *must* be something in the cells that 
do not get deleted.

Try =CODE(A6) to see if there is a non-printing character in A6, if A6 is a 
cell that is not deleting.  Also try =LEN(A6) to see if anything is 
returned.

If you get #VALUE! and 0 respectively then then is suggests that there is 
something strange going on but anything else indicates that the cell is not 
empty

You can also still send me a sample.

-- 
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

sandymann2@mailinator.com
Replace @mailinator.com with @tiscali.co.uk


"Saxman" <john.h.williamsREMOVETHIS@btinternet.com> wrote in message 
news:UbadnetUYs1xPX_VnZ2dnUVZ8j6dnZ2d@bt.com...
> Sandy Mann wrote:
>> Additionally, if you have a large amount of data it would be as well to 
>> include turning the screenupdating off:
>>
>> Option Explicit
>> Sub DeleteDate3()
>>     Dim LastRow As Long
>>     Dim dt As Date
>>     Dim cell As Range
>>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>>     dt = Date - 730
>>     Application.ScreenUpdating = False
>>     For Each cell In Range(Cells(1, 1), Cells(LastRow, 1))
>>         cell.Value = _
>>             Trim(Application.Substitute(cell.Value, _
>>                 Chr(160), ""))
>>         If IsDate(cell.Value) Then
>>             cell.NumberFormat = "d mmm yyyy"
>>                 If cell.Value < dt Then cell.ClearContents
>>         End If
>>     Next cell
>>
>>     LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>>
>>     On Error Resume Next
>>         Range(Cells(1, 1), Cells(LastRow, 1)) _
>>             .SpecialCells(xlCellTypeBlanks) _
>>                 .EntireRow.Delete
>>     On Error GoTo 0
>>     Application.ScreenUpdating = True
>> End Sub
>>
>
> This deletes the dates and 'some' empty cells + respective lines.  I guess 
> it's rather difficult without seeing the data.
>
> Below is an example of what column A looks like.  The code was set to 365 
> days, so no dates beyond that period appear which is what I require.
>
> I'm not about Wednesday, but will look Thursday am if you have posted 
> anything.
>
> No. 1   CHJIMES
> 4 Year-old Gelding    Trainer - C DORE    Jockey - T EAVES
> Date
> 14 Sep 2008
> 28 Aug 2008
> 12 Aug 2008
> 23 Jul 2008
> 14 Jul 2008
> 9 Jul 2008
> 23 Jun 2008
> 18 Jun 2008
> 9 May 2008
> 26 Apr 2008
> 12 Apr 2008
> 26 Mar 2008
> 5 Mar 2008
> 15 Feb 2008
> 4 Feb 2008
> 30 Jan 2008
> 27 Oct 2007
> 14 Oct 2007
>
>
>
> No. 2   KEEL
> 5 Year-old Gelding    Trainer - C DORE    Jockey - LIAM JONES
> Date
> 20 Jul 2008
> 12 Jul 2008
> 5 Jul 2008
>
>
>
> No. 3   FOOLS GOLD
> 3 Year-old Gelding    Trainer - G D BLAKE    Jockey - PAUL EDDERY
> Date
> 4 Aug 2008
> 9 Jul 2008
> 10 Jun 2008
> 3 Jun 2008
> 3 Apr 2008
> 11 Mar 2008
> 14 Dec 2007
> 12 Oct 2007
>
>
>
> No. 4   DAN CHILLINGWORTH
> 3 Year-old Colt    Trainer - J FANSHAWE    Jockey - R WINSTON
> Date
> 6 Sep 2008
> 25 Aug 2008
> 13 Aug 2008
> 28 Jul 2008
> 10 Jul 2008
> 31 May 2008
> 29 Oct 2007
>
>
>
> No. 5   PRIME FACTOR
> 3 Year-old Gelding    Trainer - B HILLS    Jockey - C CATLIN
> Date
> 6 Sep 2008
> 25 Aug 2008
> 9 Aug 2008
> 3 Jul 2008
> 11 Jun 2008
> 29 May 2008
> 29 Feb 2008
> 10 Feb 2008
> 16 Jan 2008
>
>
>
> No. 6   SUN CATCHER
> 5 Year-old Gelding    Trainer - P G MURPHY    Jockey - S DROWNE
> Date
> 10 Sep 2008
> 25 Jul 2008
> 2 Jul 2008
> 29 May 2008
> 20 May 2008
> 14 May 2008
> 4 May 2008
> 8 Apr 2008
> 27 Mar 2008
> 15 Mar 2008
> 23 Oct 2007
>
> 


0
sandymann2 (1054)
10/1/2008 7:49:02 AM
Sandy Mann wrote:

> If it deletes *some* rows then there *must* be something in the cells that 
> do not get deleted.
> 
> Try =CODE(A6) to see if there is a non-printing character in A6, if A6 is a 
> cell that is not deleting.  Also try =LEN(A6) to see if anything is 
> returned.
> 
> If you get #VALUE! and 0 respectively then then is suggests that there is 
> something strange going on but anything else indicates that the cell is not 
> empty

I will give it a go later.

> You can also still send me a sample.

I have sent an attachment separately.  If you need it again, let me know.

0
10/2/2008 1:31:16 PM
Reply:

Similar Artilces:

filter by date and action
I have a table with three columns: Name Date Action Fred Today this Fred Today this Fred Today that Wilma Today this I want to sort by name and by date, but only if 'this' was done more than once on the same day, and not if 'that' was done on the same day,They have to perform this more than once, and they cannot have performed that on the same day. If not in excel, mssql maybe? Thanks, Harry On Aug 18, 1:53=A0pm, Harry <hamac...@gmail.com> wrote: > I have a table with three co...

Calculate Years/Months Between Dates and then Average
We are using the formula =DATEDIF(A1,NOW(),"y") & "." & DATEDIF(A1,NOW(),"ym") to calculate the years and months from an employee hire date. Is there an easy way to average the years and months for a group of employees with the results of that formula? You could use: =AVERAGE(A1:A10*1) Array-entered, meaning press ctrl-shift-enter. But you could also just change your current formula to: =1*(DATEDIF(A1,NOW(),"y") & "." & DATEDIF(A1,NOW(),"ym")) Then just use: =AVERAGE(A1:A10) which is *not* array-entered. ...

Transaction Date VS Business Date
Our accounting department needs/wants to have all RMS SO reporting by business date opposed to transaction date. Usually these are the same unless you have sales and batches that close after midnight. For our store I would like to set 3 a.m. as the business day closing time. So when I run any type of reports I would like to get the information for a business date (range) starting at 3 a.m. till 3 a.m. the next day. I guess I could accomplish this by subtracting 3 hours from all the transaction (date and) times but I would have to do this for every single report which would be a lot of ...

Post Dated Checks
I had to prepare some post dated checks and we did not have fiscal periods set up yet to match the dates of the checks. Currently the check batches are waiting to be posted. What is the best way to handle post dated checks? If I create new fiscal years to match these dates, I will end up having 4 Open years. Is this the only way to do it? You can manage post dated checks in Microsoft Dynamics GP with the Payment Document Management module available on the Feature Pack 1 DVD image. For more info, take a look at MVP Mohammad Daoud's post on the subject at: https://communit...

Remove "Date: Yesterday" or "Date: Monday" from Outlook Inbox?
Outlook mail inbox now has headers that tell you what day the the email was sent. I find this visually annoying. Each emailalready has the time and day it was sent. I don't need the daily titles in the midst of the list of emails. How do I make them go away? I think you are talking about OL 2003 & the Arrange in Groups setting. Change it in View, Arrange by, uncheck Show in Groups. "silky" wrote: > Outlook mail inbox now has headers that tell you what day the the email was > sent. I find this visually annoying. Each emailalready has the time and day >...

strange date format problem
Hi, I downloaded some data on excel using Bloomberg. One column has dates and the other has numbers. Dates appear as 01/01/1980 format which I want in Jan-80 format. I have changed the format cell properties but it still appears as 01/01/1980. I have to goto individual cell and press F2 <enter> so see the effect. Dont know why? I cant even copy paste format after that .... TIA/amag I am not sure, but is your workbook set to Auto-Recalculate? Try pushing <F9> to do a manual re-calculation, see if that changes the formats. If it does, go to Tools (on the menu bar), Options, Ca...

How to sort by name then date?
I would like to look through all the emails to a particular person. If I click on the "To" column I can see all the emails to a particular person (actually there is a problem with that which I will mention next) but they seem to be in random order. Is there a way to have them sorted by date? (i.e. by name first, then by date). Actually, sorting on the "To" column does not get all the emails sent to a given email address. Because Outlook uses the "display as" field. It will often give different "display as" names to the same email address. C...

Concatenate including a date so that the date appears as a date
When I try to join the contents of several cells, one of which is a date and time obtained from =now(), the date and time part appears as a number. How can I make it appear as a date and time? I have tried changing the cell formats - probably there is a combination that works but I haven't found it. I also tried copying the original date cell to another cell and changing the latter cell's format and concatenating using that latter cell, but still no success. Use the TEXT function. For example, =TEXT(NOW(),"mmmm d, yyyy") would give January 6, 2010 "dd...

if statement with dates #2
I would like to have a statement like: IF(a1>0,1/1/2004) with 1/1/2004 beint a date. EXCEL is interpreting 1/1/2004 as an arithmetic statement and giving me the result of the arithemtic. I could put in the numeric offste for the date and write IF(a1>0,37987), formatting the cell as a date, but this seems awkward. What else can I do? TIA, Sanford ...

Count Unique Cells, within a date range (dates stored in separate column).
Hello All: I am attempting to create a formula that will count the number of unique cells (alpha-numeric) in an entire column (no set length, so ex: "$B:$B"). This count will be based on a date range (Between 2 dates). The dates are stored in another column (Ex: "$A:$A"). The following is an example of the cells. Dates PO_Num 1/2/2010 A123456 1/3/2010 B453453 2/2/2010 A123456 3/4/2010 C2342F3K 4/3/2010 123456 I would like to know a formula that can count the number of different PO's based on a given date range. Please help me if you...

Counting Dates?
=COUNTIF(A1:A100,"<" & NOW()) This works good for specific cells. I have a similar question. How would I do the same thing given that: 1) You only have a starting date 2) Your only wanting to count work days (in this case 4 day/wk) up to NOW() Thank you for all your help. Aviator On Thu, 6 Jan 2005 12:53:03 -0800, "Aviator" <Aviator@discussions.microsoft.com> wrote: >=COUNTIF(A1:A100,"<" & NOW()) > >This works good for specific cells. I have a similar question. > >How would I do the same thing given that: >1) You only ha...

An expression for dates from and to
I am trying to create an expression to select items from a date field falling from a certain date to a certain date. I am obviously missing something in my expression. The field name is DateComplete. How can I set up this expression to pull date from a certain date to a certain date? -- Ronnie Hi Ronnie, An example of the SQL would be: SELECT * FROM [TABLE NAME] WHERE DateComplete Between #1/1/2006# And #1/1/2007# ; On May 23, 3:52 pm, Ronnie <Ron...@discussions.microsoft.com> wrote: > I am trying to create an expression to select items from a date field falling > from a...

Returning only MAX(date) not all dates
I want to be able to list the most current date an item is checked out. As I was working through the query I used max as an aggregate function but I still can't get the simple result I want. I'd rather list the fields I have chosen and somehow select just the most current checkout date. Any help would be greatly appreciated. Here is my query: SELECT tblTerritory.TerritoryID, [TerritoryName] & " " & [TerritoryDescription] AS Description, tblTerritory.TerritoryTypeID, tblTerritoryType.TerritoryType, Max(tblTerritoryCheckout.DateCheckedOut) AS Checked...

Eliminating duplicates in a drop down list
I have constructed a database for a victim services organization with some 2000 clients. (sad commentary on today's world) One of the required reports is all the activity of an individual client. Obviously this suggests a one-to-many arrangement, as one client may be associated with more than on incident. But each callout record is unique, even though the client may be the same. I set up a popup with a text control wherein a partspec of the client's last name is entered. That information is then sent to a drop down box on the same form with this SQL in the rowsource pro...

System Date
Can anyone help me on how to force the system date to a member field of "Date" type? I could not find any help on msdn that comes with visual c++. Any hint or help will be appreciated. Thanks, Behrouzk Are you just trying to get the current date. You can use CTime::GetCurrentTime() or COleDateTime::GetCurrentTime() Tom "Behrouzk" <Behrouzk@discussions.microsoft.com> wrote in message news:D8FA4B6B-73CE-4058-B50C-C9BEBAB67E68@microsoft.com... > Can anyone help me on how to force the system date to a member field of > "Date" type? I could not fi...

Conditional Formatting
Hi, I have a spreadsheet that is for tracking work. I would like to have conditional formatting so that if the date in column E is between todays date and 4 weeks away then make it blue, if it is a date that is after 4 weeks away then make it yellow but if it is in the past make it red. Can this be done with conditional formatting or does it need vba? Also it would be nice if the whole row changes colour even if just the condition is on the date which is in column E - but if that can't be done then just the cell is fine. Thanks Assume the dates start in E2, select all dates w...

Time and date problem
Hello I have spreadsheet cell (B1) that contains a date and time: 05/11/2003 13:45:50 I have another series of cells (A1 to A100) that contain an increment of 30 seconds: 30.00 I would like to add the seconds to the date and time putting the result in column C, I have tried to do: =B1+(A1/100000) but the answer is wrong by 4 seconds and then gets worse the further down the column I go. Can somebody show me how to add the seconds to the date please. Thanks Tom Tom, Right method, wrong divider! 86,400 secs in a day.. change your 100000 to 86400 and you're there. Nikos Y. (nyannaco ...

Date subtraction -How to not show negative when 2nd date not entered
Hi, I have a section of a worksheet that just needs to show working days between two dates. For example, an order was entered on 9/2/07 and complete on 9/15/07 The formula =NETWORKDAYS(A1, A9) works perfectly except that until the "completed date" ise filled in, a negative number appears. Is there a way to have that remain blank until both dates have been entered? Thanks! Hi Edward, change your formula as =IF(A9="","",NETWORKDAYS(A1, A9)) -- Pranav Vaidya VBA Developer PN, MH-India If you think my answer is useful, please rate this post as an ANSWER...

PivotTable question
Thanks Debra, For some reason when on that Date field button in the Pivot table & choose the Group & Show Detail > Group I get a "Cannot group that selection" pop up message. I'll give the other tips a shot, I'm sure those will work. thanks again -- -= cj = ----------------------------------------------------------------------- -= cj =-'s Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1467 View this thread: http://www.excelforum.com/showthread.php?threadid=26305 If the date column contains text, or blank cells, you'll see th...

Incorrect date in creation date field
I am having an issue when creating a template I am trying to use the date field called creation date but when it is inerted into the document it shows an incorrect date? For example the file was created and saved on May 26, 2006 but the creation date field show November 26, 2002. Has anyone else seen this problem? ...

Last Balanced Date
Does anyone know a quick way to get a list of accounts and the last date they were balanced? I'm finding myself having to select each account and manually check to see if it is up to date. I would think there would be a report of some kind that would display this somewhere, but I can't seem to find one. Any suggestions? Thanks in advance...Skip Skip, I've been thinking of the same exact question ever since I made the upgrade from Money 2004 to 2005. The ability to see the last balanced date across all accounts did exist in the 2004 version, and it was very useful. It...

Convert Text Entry to Date Format
Hello We were sent a large spreadsheet with hundreds of dates entered as text in this format: 04151985. Each entry has the green triangle in the upper left corner of the cells designating the data as text. We need to change the format to 04/15/1985. I have tried DateValue with no luck. I get a "#value" error I have also tried converting the text to a number first and then formating as a date using "format/cells" but I only get a string of pound signs ####. Please help. Thanks Art Sorry, I just read some of the archived postings and figured out the solution. ...

ERROR check if a date set entered violates a previous date set
I am devloping an excel program that has a list of date sets, not necessarily in sequencial order. What I want is an ERROR CHECK if a date set violates any date set previously entered. What I was looking for was that a discharge could not be typed in as follows: 1/10/04 to 4/20/04 2/10/04 to 3/20/04 The second date falls within the first and should be invalid setting off a message or an alert of an invalid entry. I am interested in making it idiot proof so that one could not enter dates within or covering dates already entered. This one really throws me, Please help. The answer to your quest...

sequential date
Is it possible to have in sequence a date value I require four dates the same before sequencing the next date, so 01/01/11 01/01/11 01/01/11 01/01/11 02/01/11 02/01/11 02/01/11 02/01/11 03/01/11 03/01/11 03/01/11 03/01/11 etc etc Cheers In A1 : initial date In A2 : =IF(COUNTIF($A$1:A1,A1)<4,A1,A1+1) copy down as needed. Daniel > Is it possible to have in sequence a date value > > I require four dates the same before sequencing the next date, so > > 01/01/11 > 01/01/11 > 01/01/11 > 01/01/11 > 02/01/11 > 02/01/11 > 02/01/11 > 02/01/11 > 03/01/1...

Date Intervals from dates
Hi, I've created a query that lists the dates between a start date and an end date. From the list of dates, i need to find the intervals between the dates and then find the average of that. How do I get the intervals in a column in the query. thanks heaps See: Subquery basics: Get the value in another record at: http://allenbrowne.com/subquery-01.html#AnotherRecord The example is for the previous meter reading so you can subtract from the current value, but it works the same for dates. -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http:/...