Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Mark 1 more question

  1. #1
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Christchurch New Zealand
    Posts
    1,030
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    how would I then select those whole rows and copy them?

    Public Sub main()

    Dim sText As String
    Dim oRange As Range
    Dim oTargetRange As Range
    Dim sFirstRange As String
    Dim sSelect As String

    sText = "Tecpak two"
    Set oTargetRange = Sheets("Sheet1").UsedRange.Columns("A")

    Set oRange = oTargetRange.Find(what:=sText, lookat:=xlWhole)

    If Not oRange Is Nothing Then
    sFirstRange = oRange.Address
    Do
    If oRange.Value = sText Then
    sSelect = sSelect & "," & oRange.Address
    End If
    Set oRange = oTargetRange.FindNext(oRange)
    Loop While Not oRange Is Nothing And sFirstRange <> oRange.Address
    End If
    Sheets("Sheet1").Range(Right$(sSelect, Len(sSelect) - 1)).Select

    End Sub

  2. #2
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Add a line like this:


    Selection.EntireRow.Copy


    After the line with ".select"

    HTH

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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