Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default type mismatch on last part :(

I haev this code that compares dates to todays date and moves certain rows to another sheet.. The copying part works fine.. The problem i have having is in the ending of the code. I get type mismatch 13 but I dont know why. i have dates in all the columns cept the rows where there is no data anymore. Any help would be greatly appreciated.

The debugger yellows and highlights this lin
"If DateValue(ws3.Cells(1, 2)) - DateValue(ws3.Cells(iCt2, 13)) 90 Then ws3.Rows(iCt2).Delete

Thank
Jay Baxte

Here is my 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("Closed"
Set ws4 = Sheets("Archived"
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(iCt2, 13)) 90 Then ws3.Rows(iCt2).Delet
Next iCt

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default type mismatch on last part :(

datevalue("")

returns a type mismatch.

if isdate(ws3.Cells(1,2)) and isDate(ws3.Cells(ict2,13)) then
If DateValue(ws3.Cells(1, 2)) - DateValue(ws3.Cells(iCt2, 13)) _
90 Then ws3.Rows(iCt2).Delete"

End if

--
Regards,
Tom Ogilvy

"Jay Baxter" wrote in message
...
I haev this code that compares dates to todays date and moves certain rows

to another sheet.. The copying part works fine.. The problem i have having
is in the ending of the code. I get type mismatch 13 but I dont know why.
i have dates in all the columns cept the rows where there is no data
anymore. Any help would be greatly appreciated.

The debugger yellows and highlights this line
"If DateValue(ws3.Cells(1, 2)) - DateValue(ws3.Cells(iCt2, 13)) 90 Then

ws3.Rows(iCt2).Delete"

Thanks
Jay Baxter

Here is my code:

Sub ArchivedRoutine()

Dim iCt2 As Integer
Dim iRow3 As Integer
Dim iRow4 As Integer
Dim ws3 As Worksheet
Dim ws4 As Worksheet
Dim erow2 As Integer

Set ws3 = Sheets("Closed")
Set ws4 = Sheets("Archived")
iRow3 = 6
erow2 = 5
While ws4.Cells(erow2, 13) < "": erow2 = erow2 + 1: Wend
iRow4 = erow2

'copy from sheet2 to sheet3
Do Until ws3.Cells(iRow3, 13) = ""
If DateValue(ws3.Cells(1, 2)) - DateValue(ws3.Cells(iRow3, 13)) 90 Then
For iCt2 = 1 To 17
ws4.Cells(iRow4, iCt2) = ws3.Cells(iRow3, iCt2)
Next iCt2
iRow4 = iRow4 + 1
End If
iRow3 = iRow3 + 1
Loop

'delete from sheet2
For iCt2 = iRow3 To 2 Step -1
If DateValue(ws3.Cells(1, 2)) - DateValue(ws3.Cells(iCt2, 13)) 90 Then

ws3.Rows(iCt2).Delete
Next iCt2

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
Type mismatch... George[_4_] Excel Discussion (Misc queries) 7 December 19th 07 12:20 PM
type mismatch--how to fix rroach Excel Discussion (Misc queries) 2 July 14th 05 06:23 PM
Type mismatch Steve Garman Excel Programming 0 February 5th 04 07:39 AM
Type mismatch Alan Beban[_4_] Excel Programming 0 February 4th 04 08:39 PM
Type Mismatch Phil Hageman[_3_] Excel Programming 2 January 9th 04 06:11 PM


All times are GMT +1. The time now is 08:20 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"