Option Base 0
Option Explicit
Sub GetCIK()
Dim X As Long, LastRow1 As Long, OutputRow1 As Long, CellContent As String, LastRow&
Dim pos1&, pos2&, OutputRow2&
Const StartRow As Long = 1
Const DataCol As String = "A"
Const OutputSheet As String = "URLs"
Const OutputCol1 As String = "B"
Const OutputCol2 As String = "C"
LastRow = Sheets("wquery").Cells(Rows.Count, DataCol).End(xlUp).Row
OutputRow1 = Worksheets(OutputSheet).Cells(Rows.Count, OutputCol1).End(xlUp).Row
OutputRow2 = Worksheets(OutputSheet).Cells(Rows.Count, OutputCol2).End(xlUp).Row
For X = StartRow To LastRow
If Sheets("wquery").Cells(X, DataCol).Value Like "*getcompany*CIK*" Then
OutputRow1 = OutputRow1 + 1
CellContent = Sheets("wquery").Cells(X, DataCol).Value
Worksheets(OutputSheet).Cells(OutputRow1, OutputCol1).Value = Left$(Split(CellContent, ";")(1), 14)
End If
If Sheets("wquery").Cells(X, DataCol).Value Like "*""nowrap*</td>" Then
OutputRow2 = OutputRow2 + 1
CellContent = Sheets("wquery").Cells(X, DataCol).Value
pos1 = InStr(1, CellContent, """nowrap""")
pos2 = InStr(1, CellContent, "</td>")
Worksheets(OutputSheet).Cells(OutputRow2, OutputCol2).Value = Mid(CellContent, pos1 + 9, pos2 - pos1 - 9)
End If
Next X
End Sub