Results 1 to 12 of 12

Thread: find with xlprevious not working

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    VBAX Expert
    Joined
    Sep 2010
    Posts
    604
    Location
    Seems to work with some error handling for the merged cells.(Adjust as needed)
    (attached sample file)
    [VBA]Option Explicit

    Sub Find_NONBlank_Cells()

    Dim RngTar As Range
    Dim RngCur As Range
    Dim RngNex As Range

    Set RngTar = Range("A2:L20")

    Set RngCur = ActiveCell

    On Error GoTo MergedCellHandler

    Set RngNex = RngTar.Find("*", After:=RngCur, LookIn:=xlFormulas, _
    LookAt:=xlWhole, SearchDirection:=xlPrevious, SearchOrder:=xlByRows)

    On Error GoTo 0

    If RngNex Is Nothing Then

    MsgBox "No Match found"

    Else

    RngNex.Activate

    End If

    Exit Sub

    MergedCellHandler:

    Set RngNex = RngTar.Find("*", , LookIn:=xlFormulas, _
    LookAt:=xlWhole, SearchDirection:=xlPrevious, SearchOrder:=xlByRows)

    RngNex.MergeArea.Activate

    End Sub[/VBA]
    Attached Files Attached Files

Posting Permissions

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