I have a column of dates/times. Then, within UserForm, Range looks for a value > BeginDate1. Everything works great (right until the error). What I am trying to do is set the value if there is nothing found in the loop. rng1st & rng2nd will then set posted data. When there is .Cell > BeginDate1, all is good. If this value is not found, it needs to set to BeginDate1. The code below produces type mismatch.
For xRw = 2 To LastRow
If .Cells(xRw, "B") > BeginDate1 Then
Set rng1st = .Cells(xRw, "B")
Exit For
End If
ElseIf rng1st = "" Then
Set rng1st = BeginDate1
Next
For xRw = LastRow To 2 Step -1
If .Cells(xRw, "B") < EndDate1 Then
Set rng2nd = .Cells(xRw, "B")
Exit For
End If
Next
If I don't set this value when "Nothing" is found then the code below throws error: Object defined Error
For Each NewCll In .Range(rng1st, rng2nd)
MsgBoxString1 = MsgBoxString1 & NewCll.Offset(, -1).Value & " " & NewCll.Offset(, 1).Value & vbNewLine
ActiveCell.Offset(1, 0).Activate
ActiveCell = NewCll.Value
ActiveCell.Offset(0, 1).Value = NewCll.Offset(0, -1)
ActiveCell.Offset(0, 2).Value = NewCll.Offset(0, 1)
Next
I never ask until I've racked my brain. Any help GREATLY appreciated!
For xRw = 2 To LastRow
If .Cells(xRw, "B") > BeginDate1 Then
Set rng1st = .Cells(xRw, "B")
Exit For
End If
ElseIf rng1st = "" Then
Set rng1st = BeginDate1
Next
For xRw = LastRow To 2 Step -1
If .Cells(xRw, "B") < EndDate1 Then
Set rng2nd = .Cells(xRw, "B")
Exit For
End If
Next
If I don't set this value when "Nothing" is found then the code below throws error: Object defined Error
For Each NewCll In .Range(rng1st, rng2nd)
MsgBoxString1 = MsgBoxString1 & NewCll.Offset(, -1).Value & " " & NewCll.Offset(, 1).Value & vbNewLine
ActiveCell.Offset(1, 0).Activate
ActiveCell = NewCll.Value
ActiveCell.Offset(0, 1).Value = NewCll.Offset(0, -1)
ActiveCell.Offset(0, 2).Value = NewCll.Offset(0, 1)
Next
I never ask until I've racked my brain. Any help GREATLY appreciated!