Consulting

Results 1 to 3 of 3

Thread: Select Rows which has specific value (but now Entire Row selection)

  1. #1
    VBAX Regular
    Joined
    Feb 2019
    Posts
    9
    Location

    Select Rows which has specific value (but now Entire Row selection)

    Hi

    I'm trying to find some solution for selecting rows where is some specific text or value in cell.

    I use code below, which looks simple and is working, but what I want to figure is define somehow selection, I don't want to select entire row. For example I want select just from B to I range.
    Does anybody have idea?

    Sub SelectRowsIII()
    'ACTIVE
    Dim ocell As Range
    Dim rng As Range
    For Each ocell In Range("A1:A1000")
    If ocell.Value = "x" Then
    If rng Is Nothing Then
    Set rng = ocell.EntireRow
    Else
    Set rng = Union(rng, ocell.EntireRow)
    End If
    End If
    Next
    If Not rng Is Nothing Then rng.Select
    Set rng = Nothing
    Set ocell = Nothing
    End Sub
    Regards

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
      If Not rng Is Nothing Then Intersect(rng.Rows, Columns("B:I")).Select

  3. #3
    VBAX Regular
    Joined
    Feb 2019
    Posts
    9
    Location
    Working perfectly ,
    thanks

Tags for this Thread

Posting Permissions

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