VBA LastRow to Specific Text

decadence

Well-known Member
Joined
Oct 9, 2015
Messages
525
Office Version
  1. 365
  2. 2016
  3. 2013
  4. 2010
  5. 2007
Platform
  1. Windows
Hi, Is it possible to set a range in a column so it's set from last row to specific text found (header) but doesn't include the header.

Example 1 - Sets the range so only the 2 rows found (Nothing,Something)
Specific Text
Nothing
Something

<tbody>
</tbody>


Example 2 - Sets the range so only the 6 rows found (Something,Something,Something,Something,Nothing,Nothing)

Specific Text
Something
Something
Something
Something
Nothing
Nothing

<tbody>
</tbody>
 
Yes I now realise A1 is the start point, I have a few words that I need finding so is it possible to pass it to an array?
The words I am trying to find are "Temp", "Permanent", "Part Time", "Full Time" and "Flexi-time"
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try
Code:
Sub GetRng()

    Dim Ary As Variant
    Dim Cnt As Long
    Dim Fnd As Range
    Dim Rng As Range
    
    Ary = Array("[COLOR=#ff0000]Sold By[/COLOR]", "[COLOR=#ff0000]Sold On[/COLOR]", "[COLOR=#ff0000]Qty[/COLOR]")
    For Cnt = LBound(Ary) To UBound(Ary)
        Set Fnd = Cells.Find(Ary(Cnt), Range("A1"), xlValues, xlWhole, xlByRows, xlNext, False, False)
        If Not Fnd Is Nothing Then
            Set Rng = Range(Fnd.Offset(1), Cells(Rows.Count, Fnd.Column).End(xlUp))
        End If
        Rng.Select
        ' do something?
    Next Cnt
    
End Sub
Replacing values in red to match your criteria
 
Upvote 0
This is Perfect, Thank you Fluff and njimack for taking time to help me. It's much appreciated
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top