LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
don don is offline
external usenet poster
 
Posts: 8
Default For and IF statement error


The following subroutine does not work if the Msgbox is set to
comment. I get a Type mismatch error on the If Datevalue(c) <= date_
line
Yet if I take the comment ' off and it is a live line then it works.

In addition, if I don't use datevalue(c) as part of the If statement ,
rather just use If c <=date_ then it seems to work without the msgbox
line.

Why would I be having this problem???
Thanks

Don


Sub Check_PO_dates()
Dim date_ As Date
'Checks for dates and deletes line items that have
'date = or older then last run
date_ = Sheets("times").Range("g29")
Sheets("PO_scratch").Select
lr = Cells(Rows.Count, "A").End(xlUp).Row
'MsgBox Cells(2, "f").Row
For Each c In Range(Cells(2, "F"), Cells(lr, "F"))
'MsgBox c
If DateValue(c) <= date_ Then
Rows(c.Row).ClearContents
End If
Next
End Sub
 
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 Statement Error Kiley Excel Discussion (Misc queries) 3 May 18th 09 10:25 PM
Can't fix On Error statement austris Excel Discussion (Misc queries) 7 October 13th 06 07:09 AM
IF statement error D Excel Discussion (Misc queries) 4 October 4th 06 04:28 PM
Path/File access error (Error 75) using Name Statement blayne Excel Programming 7 November 22nd 05 09:20 PM
Path/File access error (Error 75) after using Name Statement blayne Excel Programming 0 November 10th 05 12:33 AM


All times are GMT +1. The time now is 08:08 AM.

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"