I am getting a type mismatch error for rTime at
If (TimeValue(rTime) >= TimeValue(lbl4AM) And TimeValue(rTime) < TimeValue(lbl11AM)) Then
Can anyone help me solve this problem? What datatype is rTime supposed to be declared as?
Sub CreateTimeBlocks()
Dim iRow As Integer, iColumn As Integer, jRow As Integer, jColumn As Integer
iRow = 1
iColumn = 3
jRow = 2
jColumn = 2
Dim rTime As String
Do While iRow < 37
Workbooks("Book1.xlsm").Sheets("Sheet1").Activate
Do Until IsEmpty(Cells(iRow, iColumn))
rTime = Cells(iRow, iColumn)
If (TimeValue(rTime) >= TimeValue(lbl4AM) And TimeValue(rTime) < TimeValue(lbl11AM)) Then
Workbooks("Book1.xlsm").Sheets("Sheet2").Activate
Cells(jRow, jColumn) = Cells(jRow, jColumn) + 1
Else
Workbooks("Book1.xlsm").Sheets("Sheet3").Activate
Cells(jRow, jColumn) = Cells(jRow, jColumn) + 1
End If
Workbooks("Book1.xlsm").Sheets("Sheet1").Activate
iColumn = iColumn + 1
Loop
jRow = jRow + 1
iColumn = 3
iRow = iRow + 1
Loop
End Sub
If (TimeValue(rTime) >= TimeValue(lbl4AM) And TimeValue(rTime) < TimeValue(lbl11AM)) Then
Can anyone help me solve this problem? What datatype is rTime supposed to be declared as?
Sub CreateTimeBlocks()
Dim iRow As Integer, iColumn As Integer, jRow As Integer, jColumn As Integer
iRow = 1
iColumn = 3
jRow = 2
jColumn = 2
Dim rTime As String
Do While iRow < 37
Workbooks("Book1.xlsm").Sheets("Sheet1").Activate
Do Until IsEmpty(Cells(iRow, iColumn))
rTime = Cells(iRow, iColumn)
If (TimeValue(rTime) >= TimeValue(lbl4AM) And TimeValue(rTime) < TimeValue(lbl11AM)) Then
Workbooks("Book1.xlsm").Sheets("Sheet2").Activate
Cells(jRow, jColumn) = Cells(jRow, jColumn) + 1
Else
Workbooks("Book1.xlsm").Sheets("Sheet3").Activate
Cells(jRow, jColumn) = Cells(jRow, jColumn) + 1
End If
Workbooks("Book1.xlsm").Sheets("Sheet1").Activate
iColumn = iColumn + 1
Loop
jRow = jRow + 1
iColumn = 3
iRow = iRow + 1
Loop
End Sub