Consulting

Results 1 to 3 of 3

Thread: Solved: Select Specific Cell Range

  1. #1
    VBAX Regular
    Joined
    Feb 2010
    Posts
    41
    Location

    Solved: Select Specific Cell Range

    I am working with this code...

    [vba]Dim rng As Range, cell As Range, del As Range
    Set rng = Intersect(Range("A:A"), ActiveSheet.UsedRange)
    For Each cell In rng
    If (cell.Value) = "CASH/CHECKING ACCOUNT" _
    Or (cell.Value) = "CHECKING ACCOUNT" _
    Or (cell.Value) = "CASH/CHECKING ACCOUNT" _
    Or (cell.Value) = "CASH/CHECKING ACCOUNT" Then
    If del Is Nothing Then
    Set del = cell
    Else: Set del = Union(del, cell)
    del.Offset(0, 6).FormulaR1C1 = "Leave 100k"
    del.EntireRow.Select
    With Selection.Interior
    .ColorIndex = 6
    .Pattern = xlSolid
    End With
    End If
    End If
    Next cell
    On Error Resume Next[/vba]
    Instead of selecting the entire row (del.EntireRow.Select), how would I simply select a range like A6:G6. Essentially, I just want to highlight the range instead of the entire row. Thanks for the help.

  2. #2
    VBAX Mentor
    Joined
    Jun 2004
    Posts
    363
    Location
    Try this version:
    [VBA]Dim rng As Range, cell As Range, del As Range
    Set rng = Intersect(Range("A:A"), ActiveSheet.UsedRange)

    For Each cell In rng
    If (cell.Value) = "CASH/CHECKING ACCOUNT" _
    Or (cell.Value) = "CHECKING ACCOUNT" _
    Or (cell.Value) = "CASH/CHECKING ACCOUNT" _
    Or (cell.Value) = "CASH/CHECKING ACCOUNT" Then

    Set del = cell
    del.Offset(0, 6).FormulaR1C1 = "Leave 100k"
    With Range(del, del.Offset(0, 6)).Interior
    .ColorIndex = 7
    .Pattern = xlSolid
    End With

    End If

    Next cell
    On Error Resume Next[/VBA]

  3. #3
    VBAX Regular
    Joined
    Feb 2010
    Posts
    41
    Location
    That works perfectly. Thank you so much for taking the time. I really appreciate it.

Posting Permissions

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