Hello,
I have an enormous data set in a single column (180k line config file dump), and need to copy any ranges where the first cell contains a string. The ranges are delimited by a specific series of cells, and the first cell in a range starts with the same text string. The string I need to search by is a 7-digit id number.
I found a script that copies cells containing a string to a new worksheet: Search for substring and copy results to new worksheet?
This is half of what I am looking to accomplish.
I would like to copy the entire ranges of cells where the first cell in the range contains the specified string.
Sample Data
<tbody>
</tbody>
This is the code DMcClenagan posted:
Many thanks, in advance.
I have an enormous data set in a single column (180k line config file dump), and need to copy any ranges where the first cell contains a string. The ranges are delimited by a specific series of cells, and the first cell in a range starts with the same text string. The string I need to search by is a 7-digit id number.
I found a script that copies cells containing a string to a new worksheet: Search for substring and copy results to new worksheet?
This is half of what I am looking to accomplish.
I would like to copy the entire ranges of cells where the first cell in the range contains the specified string.
Sample Data
ssssssssss |
ssssssssss |
ACO: site.com: 1234567 - name1 |
DataPoint1 |
DataPoint2 |
DataPoint3 |
DataPoint4 |
ssssssssss |
ssssssssss |
ACO: site2.com: 7539516 - name2 |
DataPoint2 |
DataPoint4 |
DataPoint4 |
ssssssssss |
ssssssssss |
<tbody>
</tbody>
This is the code DMcClenagan posted:
Code:
Sub FindStringManyTimes()
Dim ii As Integer
Dim gFind, gPlug As Long
Dim bRet As Boolean
Dim oo As Object
Sheets.Add
ActiveSheet.Name = "ListOfFinds"
For ii = 2 To Sheets.Count
With Sheets(ii)
bRet = bAnyCells(Sheets(ii).Name)
If bRet Then
For Each oo In .Cells.SpecialCells(xlCellTypeConstants)
gFind = InStr(1, oo.Value, "ACO: ")
If gFind > 0 Then
gPlug = gPlug + 1
Cells(gPlug, 1).Value = oo.Value
Cells(gPlug, 2).Value = Sheets(ii).Name
Cells(gPlug, 3).Value = oo.Address(False, False)
End If
Next oo
End If
End With
Next ii
End Sub
Function bAnyCells(sSheet As String) As Boolean
Dim oo As Object
On Error GoTo Bye
With Sheets(sSheet)
For Each oo In .Cells.SpecialCells(xlCellTypeConstants)
Next oo
End With
bAnyCells = True
Bye:
On Error GoTo 0
End Function
Many thanks, in advance.