Data's are pasted into cells in Range C which contains ticket ranges.
Below are the ticket ranges
ST388 - ST404
CR510 - CR528
What the macro should do -
As soon as the data is pasted in Range C, Range C should get highlight in RED if the data contains above mentioned Ticket Ranges. (Without pressing ALT+F8)
The above code highlights Range C if it only contains the Ticket Range
Ex :
Range C - - - - Result
ST388 - - - - - Highlights in RED
Since the data will be recorded across multiple sheets, the macro should highlight Range C no matter which sheet the data is pasted.
Note -
The code works only for ticket range ST388 - ST404.
It should also work for CR510 - CR528
Have attached sample sheet with dummy data across 3 sheets
Below are the ticket ranges
ST388 - ST404
CR510 - CR528
What the macro should do -
As soon as the data is pasted in Range C, Range C should get highlight in RED if the data contains above mentioned Ticket Ranges. (Without pressing ALT+F8)
Code:
Sub Format()
Dim LastRow As Double
Dim sht As Worksheet: Set sht = ThisWorkbook.Sheets("Sheet1")
Dim i As Double
LastRow = sht.Cells(sht.Rows.Count, "C").End(xlUp).Row + 1
With sht
For i = 1 To LastRow
Debug.Print Right(.Range("C" & i), 3)
Debug.Print Right(.Range("C" & i), 3) > 387
If Right(.Range("C" & i), 3) > 387 And Right(.Range("C" & i), 3) < 405 Then
.Range("C" & i).Interior.Color = RGB(255, 0, 0)
End If
Next i
End With
End Sub
The above code highlights Range C if it only contains the Ticket Range
Ex :
Range C - - - - Result
ST388 - - - - - Highlights in RED
Since the data will be recorded across multiple sheets, the macro should highlight Range C no matter which sheet the data is pasted.
Note -
The code works only for ticket range ST388 - ST404.
It should also work for CR510 - CR528
Have attached sample sheet with dummy data across 3 sheets