Highlight Rows in a Range that Meet Some Criteria

Option Explicit
Sub highlight()
 
' SelectValues Macro
' Selects values that will become criteria for shading rows
'
' Keyboard Shortcut: Ctrl+Shift+U
'
    'First, read in the values for shading
    Dim l As Double
    Dim m As Double
 
    l = Sheets("Criteria").Range("B2").Value
    m = Sheets("Criteria").Range("B3").Value
 
   'Set up variables that you'll need for below code
   Dim c As Range
   Dim r As Range
   Dim n As Double
 
   'Input Range to be evaluated
   Set r = Application.InputBox(prompt:="Input your range", Type:=8)
 
   'On error in below loop, just keep going
   On Error Resume Next
 
   'loop through all the values in the range
   For Each c In r
 
      'convert to number if value happens to be text
      c = Val(c)
 
      'evaluates and colors rows based on your criteria spreadsheet
      If c > l And c < 0 Then c.EntireRow.Interior.ColorIndex = 6
      If c < l And c > m Then c.EntireRow.Interior.ColorIndex = 44
      If c < m Then c.EntireRow.Interior.ColorIndex = 3
 
   Next c
 
End Sub
Posted in VB