Results 1 to 6 of 6

Thread: Replace in a sheet and not the entire workbook

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,285
    Location
    This routine will search in a specified range for 'Total'. Probably indeed a 'bug' or malfunctioning.
    Sub test()
        Dim rng As Range, result As Range
        Dim firstaddress As String, vmessage As String
        Dim lrow As Long
        lrow = Worksheets(1).Range("A" & Rows.Count).End(xlUp).Row
        Set rng = Worksheets(1).Range("A1:A" & lrow)
        vmessage = "Item 'Total' was found on rows :" & vbCrLf
        With rng
            Set result = .Find("Total", LookIn:=xlValues)
            If Not result Is Nothing Then
                firstaddress = result.Address
                Do
                    vmessage = vmessage & "- " & result.Row & vbCrLf
                    Set result = .FindNext(result)
                Loop While Not result Is Nothing And result.Address <> firstaddress
            End If
        End With
        MsgBox vmessage, vbInformation, "Requested info ..."
    End Sub
    Charlize
    Last edited by Aussiebear; 02-20-2025 at 04:49 PM.

Posting Permissions

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