Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If condition to exclude value in column.... (2000 sr 1)

    I want to insert this condition:
    (TIPO_SOSP is a var)

    If not TIPO_SOSP is in the range sheets("mysheet_name").range(" E2:E14") Then...
    ecc...
    how to?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: If condition to exclude value in column.... (2000 sr 1)

    You should know this by now:

    Dim rng As Range
    Set rng = Sheets("mysheet_name").Range("E2:E14").Find(What:= TIPO_SOSP, LookIn:=xlValues, LookAt:=xlWhole)
    If rng Is Nothing Then
    ' not found
    Else
    ' found
    End If

    If you want to search for part of a cell value, use xlPart instead of xlWhole.

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: If condition to exclude value in column.... (2000 sr 1)

    Why not use a MATCH like in <post:=575,979>post 575,979</post:>

    Dim lRow As Long
    lRow = 0
    on error resume next
    lRow = Application.WorksheetFunction.match(TIPO_SOSP, _
    sheets("mysheet_name").range(" E2:E14") , False)
    on error GoTo 0
    If lRow = 0 Then
    'Code for Not found
    Else
    'Code for found
    End If

    lRow contains the "index row" it is was found in (if lrow = 1 then it is in row 2, if lrow = 13 then in row 14, since you start at row 2 in the range)

    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •