ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Extract rows with specific text in a column (https://www.excelbanter.com/excel-programming/330046-extract-rows-specific-text-column.html)

TroyB[_2_]

Extract rows with specific text in a column
 
Hi,

I've got a large spreadsheet that I'd like to extract all the rows with the
words "PROVISIONAL QUANTITY" or "PROVISIONAL SUM" within the text in a
particular column.
ie - Some cells in Column C have the words "PROVISIONAL QUANTITY" or
"PROVISIONAL SUM" in the text somewhere. I need the data from the entire
row if col C has these words in the cell text.

I suspect this could be done by either 1) deleting all rows that dont
contain these words, or 2) selecting all the rows with the words and copying
into a blank worksheet.
Is there an easy way to achieve this or is a macro required. If macro
required, any help on the below macro would be great.

Sub ProvSumCopy()
Dim rng As Range
Dim cell As Range
Dim start_str As Integer

Set rng = Selection
For Each cell In rng
start_str = InStr(cell.Value, "PROVISIONAL SUM")
If start_str Then
ActiveRow.Select
End If
start_str = InStr(cell.Value, "PROVISIONAL QUANTITY")
If start_str Then
ActiveRow.Select
End If

Next

End Sub

Thanks
Troy










TroyB[_2_]

Extract rows with specific text in a column
 
I've actually found the answer to my own question. For all those
interested, follow the below hyperlink relating to Advanced Filters.
http://www.contextures.com/xladvfilter01.html

Regards
Troy

"TroyB" wrote in message
...
Hi,

I've got a large spreadsheet that I'd like to extract all the rows with
the words "PROVISIONAL QUANTITY" or "PROVISIONAL SUM" within the text in a
particular column.
ie - Some cells in Column C have the words "PROVISIONAL QUANTITY" or
"PROVISIONAL SUM" in the text somewhere. I need the data from the entire
row if col C has these words in the cell text.

I suspect this could be done by either 1) deleting all rows that dont
contain these words, or 2) selecting all the rows with the words and
copying into a blank worksheet.
Is there an easy way to achieve this or is a macro required. If macro
required, any help on the below macro would be great.

Sub ProvSumCopy()
Dim rng As Range
Dim cell As Range
Dim start_str As Integer

Set rng = Selection
For Each cell In rng
start_str = InStr(cell.Value, "PROVISIONAL SUM")
If start_str Then
ActiveRow.Select
End If
start_str = InStr(cell.Value, "PROVISIONAL QUANTITY")
If start_str Then
ActiveRow.Select
End If

Next

End Sub

Thanks
Troy













All times are GMT +1. The time now is 03:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com