Select by Value

An input box will prompt for the value to be selected.

Sub SelectByValue()
 On Error Resume Next
 Application.ScreenUpdating = False
 Dim c As Range
 Dim myValue As String
 Dim r As Long
 Dim myArea As Range
 Dim myRange As Range
 Set myArea = ActiveSheet.UsedRange
 myValue = InputBox("Please enter the cell's number or text to select")
 For Each c In myArea
  If c.Text = myValue Then
   If r = 0 Then
    Set myRange = c
    r = 1
   Else
    Set myRange = Union(myRange, c)
   End If
  End If
 Next c
 myRange.Select
 Application.ScreenUpdating = True
End Sub



© Copyright andrewsexceltips.net All Rights Reserved.