Sub Chart_Laid(StartC As Long, StartR As Long, StartD As Date, EndD As Date)
Dim Cell As Range
Dim RowShift As Integer
Dim ColShift As Integer
Dim TimeCheck As Double
Dim wsLaid As Worksheet, wsSleepChart As Worksheet
Set wsLaid = Worksheets("Sheet2")
Set wsSleepChart = Worksheets("Sleep Chart")
With wsLaid
For Each Cell In .Columns(3)
'****************************************************
If Cell = "Laid Down" Then
TimeCheck = .Cells(Cell.Row, 2).Value
'****************************************************
If After_Midnight(TimeCheck) Then
RowShift = -1
ColShift = 0
Else
RowShift = 0
ColShift = Application.WorksheetFunction.Round(-2 * (0.5 / (0.25 / 24)), 0)
End If
With wsSleepChart.Cells(.Cells(Cell.Row, StartC - 51).Value - StartD + StartR + RowShift, Application.WorksheetFunction.Round((.Cells(Cell.Row, StartC - 50).Value) / (0.25 / 24), 0) + StartC + ColShift).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Color = -16776961
.Weight = xlThick
End With
End If
If IsEmpty(.Cells(Cell.Row, 1)) Then
If .Cells(Cell.Row - 1, 1) = EndD Then Exit Sub
End If
Next Cell
End With
End Sub
I am getting a Type mismatch error in either the 1st or second line between the ***** lines. I had this working, then I was stupid and went through and cleaned a bunch of things up and now I do not recall what I changed to make it stop working.
UPDATE:
The error occurs when stepping through the sub when the following line is selected and I press F8.
If Cell = "Laid Down" Then
I have also tried
If Cell.Value = "Laid Down" Then
and
If Cell.Value2 = "Laid Down" Then
all produce the error.