Macro run time error 6

macdca

Board Regular
Joined
Sep 28, 2010
Messages
170
I have a macro, that has been working fine for months until last week when I have started getting a runtime error. My code is below, and the error is highlighted in red? can anyone help??

Sub ConsolidateRows3()
Dim Rw As Long
Dim LR As Long
Dim DelRng As Range
If MsgBox("Consolidate the data on Active sheet?", vbYesNo, "This Sheet?") = vbNo Then Exit Sub
Application.ScreenUpdating = False
'Sheets("RawData").Visible = True
Sheets("RawData").Select
'Copy data sheet
ActiveSheet.Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = "Consolidated"
'Sort by column A (MachineID)
Range("A1").CurrentRegion.Sort Key1:=Range("A2"), Order1:=xlAscending, _
Key2:=Range("B2"), Order2:=xlAscending, Header:=xlYes
'Sort by column F (PatientID), B (ScheduledStartDate) and M (PlanID)
Range("A1").CurrentRegion.Sort Key1:=Range("F2"), Order1:=xlAscending, _
Key2:=Range("M2"), Order2:=xlAscending, Header:=xlYes

LR = Range("A" & Rows.Count).End(xlUp).Row
Set DelRng = Range("A" & Rows.Count)
'Merge row by row from the bottom up
For Rw = LR To 3 Step -1
'compare B, F and M and only merge if they match
If Range("B" & Rw) = Range("B" & Rw - 1) And _
Range("F" & Rw) = Range("F" & Rw - 1) And _
Range("M" & Rw) = Range("M" & Rw - 1) Then
'Date of Referral
If Range("D" & Rw - 1) = "" Then
Range("D" & Rw - 1) = Int(Range("D" & Rw))
Else
Range("D" & Rw - 1) = Int(Range("D" & Rw - 1))
End If
'Decision to Treat Date
If Range("E" & Rw - 1) = "" Then
Range("E" & Rw - 1) = Int(Range("E" & Rw))
Else
Range("E" & Rw - 1) = Int(Range("E" & Rw - 1))
End If
'DiagCode
If Range("N" & Rw) <> "" Then
If Range("N" & Rw - 1) = "" Then
Range("N" & Rw - 1) = Range("N" & Rw)
Else
Range("N" & Rw - 1) = Range("N" & Rw - 1) & " / " & Range("N" & Rw)
End If
End If
'Tumour Group
If Range("O" & Rw) <> "" Then
If Range("O" & Rw - 1) = "" Then
Range("O" & Rw - 1) = Range("O" & Rw)
Else
Range("O" & Rw - 1) = Range("O" & Rw - 1) & " / " & Range("O" & Rw)
End If
End If
'Modality T
If Range("T" & Rw) <> "" Then
If Range("T" & Rw - 1) = "" Then
Range("T" & Rw - 1) = Range("T" & Rw)
Else
Range("T" & Rw - 1) = Range("T" & Rw - 1) & " / " & Range("T" & Rw)
End If
End If
' 'Modality U
' If Range("U" & Rw) <> "" Then
' If Range("U" & Rw - 1) = "" Then
' Range("U" & Rw - 1) = Range("U" & Rw)
' Else
' If Range("U" & Rw - 1) <> Range("U" & Rw) Then _
' Range("U" & Rw - 1) = Range("U" & Rw - 1) & " / " & Range("U" & Rw)
' End If
' End If
'Flag the row for deletion later
Set DelRng = Union(DelRng, Range("A" & Rw))
End If
Next Rw

'Delete unneeded rows
DelRng.EntireRow.Delete xlShiftUp
Set DelRng = Nothing
'Add new column formulas
LR = Range("A" & Rows.Count).End(xlUp).Row
With Range("U2:U" & LR)
.FormulaR1C1 = _
"=IF(RC3="""", """", DATEDIF(RC3,RC2,""d""))"
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OR(AND(LEFT($L1,1)=""Palliative"",$U1>=18,ISNUMBER($U1)), AND(LEFT($L1,1)=""Radical"",$U1>=40,ISNUMBER($U1)))"
.FormatConditions(1).Font.ColorIndex = 3
End With
With Range("V2:V" & LR)
.FormulaR1C1 = _
"=IF(RC5="""", """", DATEDIF(RC5,RC2,""d""))"
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OR(AND(LEFT($L1,1)=""Palliative"",$V1>=18,ISNUMBER($V1)), AND(LEFT($L1,1)=""Radical"",$V1>=40,ISNUMBER($V1)))"
.FormatConditions(1).Font.ColorIndex = 3
End With
'Sort by column A (MachineID)
Range("A1").CurrentRegion.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlYes
'Cleanup
Rows(1).Font.Bold = True
Columns.AutoFit
Columns("D:E").NumberFormat = "dd/mm/yy"
Range("U2:V" & LR).NumberFormat = "0"
Application.ScreenUpdating = True
Range("A2").Select
ActiveWindow.FreezePanes = True
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I can't see anythign wrong with it, at first sight.

When the error occurs, you will be able to click "debug".

When you inspect the contents of the variables, are they correct and what you expect? Did the (source of the) data change for one reason or another?

PS: Please use code tags when you paste VBA code on the forum.
 
Upvote 0
everything seems to be the same in the source data bt in the consolidated sheet (when it does run) the dates in columns D and E are all <TABLE style="WIDTH: 44pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=58 border=0 x:str><COLGROUP><COL style="WIDTH: 44pt; mso-width-source: userset; mso-width-alt: 2121" width=58><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD class=xl24 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 44pt; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" align=right width=58 height=17 x:num="10">10/01/00</TD></TR></TBODY></TABLE>??
 
Upvote 0
Please post screenshots to make it a little bit less vague. All we can do now is guess.
 
Upvote 0
PART OF THE EXTRACT:

<TABLE style="WIDTH: 366pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=488 border=0 x:str><COLGROUP><COL style="WIDTH: 42pt; mso-width-source: userset; mso-width-alt: 2048" width=56><COL style="WIDTH: 81pt; mso-width-source: userset; mso-width-alt: 3949" span=4 width=108><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 42pt; BORDER-BOTTOM: #e0dfe3; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" width=56 height=17>A</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 81pt; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" width=108>B</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 81pt; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" width=108>C</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 81pt; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" width=108>D</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 81pt; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" width=108>E</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>TRA</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40758.361111111109">03/08/11</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40730">06/07/11</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40730">06/07/11</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent"></TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>TRA</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40758.361111111109">03/08/11</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40730">06/07/11</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent"></TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent"></TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>TRA</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40758.361111111109">03/08/11</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40730">06/07/11</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent"></TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent"></TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>TRA</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40758.361111111109">03/08/11</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40730">06/07/11</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40730">06/07/11</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent"></TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>TRA</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40758.361111111109">03/08/11</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40730">06/07/11</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent"></TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40730">06/07/11</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>TRA</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40758.361111111109">03/08/11</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40730">06/07/11</TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent"></TD><TD class=xl22 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40730">06/07/11</TD></TR></TBODY></TABLE>

should be like:

<TABLE style="WIDTH: 280pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=371 border=0 x:str><COLGROUP><COL style="WIDTH: 46pt; mso-width-source: userset; mso-width-alt: 2230" width=61><COL style="WIDTH: 71pt; mso-width-source: userset; mso-width-alt: 3437" width=94><COL style="WIDTH: 73pt; mso-width-source: userset; mso-width-alt: 3547" width=97><COL style="WIDTH: 44pt; mso-width-source: userset; mso-width-alt: 2121" width=58><COL style="WIDTH: 46pt; mso-width-source: userset; mso-width-alt: 2230" width=61><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD class=xl24 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 46pt; BORDER-BOTTOM: #e0dfe3; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" width=61 height=17>A</TD><TD class=xl27 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 71pt; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" width=94>B</TD><TD class=xl27 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 73pt; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" width=97>C</TD><TD class=xl25 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 44pt; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" width=58>D</TD><TD class=xl25 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 46pt; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" width=61>E</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>TRA</TD><TD class=xl28 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40758.361111111109">03/08/11</TD><TD class=xl28 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40730">06/07/11</TD><TD class=xl26 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="10">10/01/00</TD><TD class=xl26 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="10">10/01/00</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>TRA</TD><TD class=xl28 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40758.361111111109">03/08/11</TD><TD class=xl28 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40730">06/07/11</TD><TD class=xl26 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="10">10/01/00</TD><TD class=xl26 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="10">10/01/00</TD></TR></TBODY></TABLE>

AS PER THE SPEC OF THE MACRO, BUT THE FORMATTING OF THE DATES IS SOMEHOW LOST FROM 06/07/11 (D/M/YY) TO 10/01/00??
 
Last edited:
Upvote 0
SORRY THE SECOND TABLE SHOULD HAVE READ:

<TABLE style="WIDTH: 280pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=371 border=0 x:str><COLGROUP><COL style="WIDTH: 46pt; mso-width-source: userset; mso-width-alt: 2230" width=61><COL style="WIDTH: 71pt; mso-width-source: userset; mso-width-alt: 3437" width=94><COL style="WIDTH: 73pt; mso-width-source: userset; mso-width-alt: 3547" width=97><COL style="WIDTH: 44pt; mso-width-source: userset; mso-width-alt: 2121" width=58><COL style="WIDTH: 46pt; mso-width-source: userset; mso-width-alt: 2230" width=61><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD class=xl24 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 46pt; BORDER-BOTTOM: #e0dfe3; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" width=61 height=17>A</TD><TD class=xl27 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 71pt; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" width=94>B</TD><TD class=xl27 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 73pt; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" width=97>C</TD><TD class=xl25 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 44pt; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" width=58>D</TD><TD class=xl25 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; WIDTH: 46pt; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" width=61>E</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>TRA</TD><TD class=xl28 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40758.361111111109">03/08/11</TD><TD class=xl28 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40730">06/07/11</TD><TD class=xl26 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="10">10/01/00</TD><TD class=xl26 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="10">10/01/00</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>TRA</TD><TD class=xl28 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40758.361111111109">03/08/11</TD><TD class=xl28 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="40730">06/07/11</TD><TD class=xl26 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="10">10/01/00</TD><TD class=xl26 style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent" align=right x:num="10">10/01/00</TD></TR></TBODY></TABLE>
 
Upvote 0
'Date of Referral
If Range("D" & Rw - 1) = "" Then
Range("D" & Rw - 1) = Int(Range("D" & Rw))
Else
Range("D" & Rw - 1) = Int(Range("D" & Rw - 1))
End If
'Decision to Treat Date
If Range("E" & Rw - 1) = "" Then
Range("E" & Rw - 1) = Int(Range("E" & Rw))
Else
Range("E" & Rw - 1) = Int(Range("E" & Rw - 1))
End If
This seems to be the problem, removing the Int seems to make it work - why would that be??
 
Upvote 0
Int, in this context, could be used to remove the hours and minutes from a given date.

In Excel the latter are represented by decimal numbers. Int will only retain the INTEGER of the number/date.

Again, please use code tags when you paste VBA code on the forum.
 
Upvote 0

Forum statistics

Threads
1,224,544
Messages
6,179,430
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top