• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Look in the Entire Column

dparteka

Member
This code checks cell B5 for a hyphen and if it’s there then it displays Commandbutton2, works good. I'm looking to modify it slightly so it looks in the entire column or a range like B5:B24 for example... thanks for looking, any help will be very appreciative.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Cells(5, 2).Value = "-" Then
        Me.CommandButton2.Visible = True
    Else
        Me.CommandButton2.Visible = False
    End If
End Sub
 
How about
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Dim Fnd As Range
 
  Set Fnd = Range("B5:B24").Find("-", , xlValues, xlWhole, , , , , False)
  If Not Fnd Is Nothing Then
      Me.CommandButton2.Visible = True
  Else
      Me.CommandButton2.Visible = False
  End If
End Sub
 
Back
Top