LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default delete all rows where cell is not date format

On Feb 10, 8:33*pm, burl_h wrote:
On Feb 10, 8:06*pm, "Rick Rothstein \(MVP - VB\)"





wrote:
The cell property you need to check is NumberFormat, not just Format.


Rick


"burl_h" wrote in message


...


I'm having a problem with the following code, for some reason I can't
get the correct syntax.


Sub delete_not_date
Dim datarng As Range
lastrow = Cells(rows.Count, "B").End(xlUp).Row
Set datarng = Range("b2:b" & lastrow)
* * *For i = lastrow To 1 Step -1
* * * * *For Each cell In datarng
* * * * * * *If Not cell.Format = "mm/dd/yyyy" Then
* * * * * * * * *cell.EntireRow.Delete
* * * * * * *End If
* * * * *Next cell
* * *Next i
End Sub


My problem is the date format, I tried many variations but can't get
anything to work.


I did check the format on the cells and found them to be a custom
format written as "mm\/mm\/yyyy". The data originated from a Crystal
report, hence perhaps the weird date format.


The objective is to delete all rows that don't contain a date value.


Thanks.- Hide quoted text -


- Show quoted text -


Rick,

Thanks for your solution, it worked fine. I did however have to change
the format to "mm\/dd\/yyyy" to make it work, the little quirk with
Crystal reports no doubt.

Thanks
burl_h- Hide quoted text -

- Show quoted text -


Dave,

Yes that was a typo on my part "mm\/mm\/yyyy" should be "mm\/dd\/yyyy"

I did try your solution and it worked great, thanks very much for
everyone's help.

Thanks
burl_h
 
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
if cell is not date format delete row burl_h Excel Programming 0 February 11th 08 12:27 AM
if cell is not date format delete row burl_h Excel Programming 0 February 11th 08 12:27 AM
if cell is not date format delete row burl_h Excel Programming 0 February 11th 08 12:27 AM
How do you format an auto update to delete rows with expired date Rneedshelp Excel Worksheet Functions 0 May 29th 07 04:30 PM
macro to find date format in a cell and delete that entire row vikram Excel Programming 8 April 30th 04 06:00 PM


All times are GMT +1. The time now is 02:46 PM.

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

About Us

"It's about Microsoft Excel"