michaeltsmith93
Board Regular
- Joined
- Sep 29, 2016
- Messages
- 83
Hi there,
Any thoughts on why I'm getting a 1004 error on the statement in red? Presumably the same thing is wrong with the three below it.
Any thoughts on why I'm getting a 1004 error on the statement in red? Presumably the same thing is wrong with the three below it.
Code:
Sub UpdateTier1ResultsM()
Dim k1 As Worksheet
Dim StartRow As Long, LRow As Long, WMSPCol As Long, MMSEPCol As Long, CDRPCol As Long, WMSScoreCol As Long, MMSEScoreCol As Long, _
CDRMScoreCol As Long, CDRGScoreCol, AgeCol As Long, WMSScore As Long, MMSEScore As Long, CDRMScore As Long, CDRGScore As Long
Dim FullRange As Range
Set k1 = Worksheets("CognitiveDetails")
StartRow = 6
LRow = k1.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
Set FullRange = Range(Rows(StartRow).EntireRow, Rows(LRow).EntireRow)
WMSScoreCol = k1.Range(Cells(5, 1), Cells(5, 200)).Find("WMS-IV Logical Memory II Total Raw Score - Tier 1", searchorder:=xlByColumns, searchdirection:=xlNext).Column
MMSEScoreCol = k1.Range(Cells(5, 1), Cells(5, 200)).Find("Total eMMSE Score - Tier 1", searchorder:=xlByColumns, searchdirection:=xlNext).Column
CDRMScoreCol = k1.Range(Cells(5, 1), Cells(5, 200)).Find("CDR - Memory Score - Tier 1", searchorder:=xlByColumns, searchdirection:=xlNext).Column
CDRGScoreCol = k1.Range(Cells(5, 1), Cells(5, 200)).Find("CDR - Global Score - Tier 1", searchorder:=xlByColumns, searchdirection:=xlNext).Column
WMSPCol = k1.Range(Cells(5, 1), Cells(5, 200)).Find("Passed WMS? - Tier 1", searchorder:=xlByColumns, searchdirection:=xlNext).Column
MMSEPCol = k1.Range(Cells(5, 1), Cells(5, 200)).Find("Passed MMSE? - Tier 1", searchorder:=xlByColumns, searchdirection:=xlNext).Column
CDRPCol = k1.Range(Cells(5, 1), Cells(5, 200)).Find("Passed CDR? - Tier 1", searchorder:=xlByColumns, searchdirection:=xlNext).Column
AgeCol = k1.Range(Cells(5, 1), Cells(5, 200)).Find("current age", searchorder:=xlByColumns, searchdirection:=xlNext).Column
[COLOR=#ff0000]WMSScore = k1.Cells(r, WMSScoreCol).Value[/COLOR]
MMSEScore = k1.Cells(r, MMSEScoreCol).Value
CDRMScore = k1.Cells(r, CDRMScoreCol).Value
CDRGScore = k1.Cells(r, CDRGScoreCol).Value
For Each r In FullRange
If IsEmpty(WMSScore) = False Then
If IsEmpty(Cells(r, WMSPCol).Value) = True Then
Select Case AgeScore
Case AgeCol > 50 And AgeCol < 65 And WMSScore < 16
Cells(r, WMSPCol).Value = "YES"
Case AgeCol >= 65 And AgeCol < 70 And WMSScore < 13
Cells(r, WMSPCol).Value = "YES"
Case AgeCol >= 70 And AgeCol < 75 And WMSScore < 12
Cells(r, WMSPCol).Value = "YES"
Case AgeCol >= 75 And AgeCol < 80 And WMSScore < 10
Cells(r, WMSPCol).Value = "YES"
Case AgeCol >= 80 And WMSScore < 8
Cells(r, WMSPCol).Value = "YES"
Case Else
Cells(r, WMSPCol).Value = "NO"
End Select
End If
End If
If IsEmpty(MMSEScore) = False Then
If IsEmpty(Cells(r, MMSEPCol).Value) = True Then
If MMSEScore >= 22 Then
Cells(r, MMSEPCol).Value = "YES"
Else
Cells(r, MMSEPCol).Value = "NO"
End If
End If
End If
If IsEmpty(CDRMScore) = False And IsEmpty(CDRGScore) = False Then
If IsEmpty(Cells(r, CDRPCol).Value) = True Then
If CDRMScore > 0 And (CDRGScore = 0.5 Or CDRGScore = 1) Then
Cells(r, CDRPCol).Value = "YES"
Else
Cells(r, CDRPCol).Value = "NO"
End If
End If
End If
Next r
End Sub