Extracting a text string Problem

fari1

Active Member
Joined
May 29, 2011
Messages
362
my below code is perfect of extracting my another text string, but when i modify it to extract my another text string, it is not giving me results, trying real hard but unable to find the problem.

the text string to find is
HTML:
BIK=0000055135
out of this line

HTML:
<td bgcolor="#E6E6E6" valign="top" align="left"><a href="/chi-kin/browse-gar?action=getcompany&BIK=0000055135&owner=include&count=100">KELLY SERVICES INC (0000055135) (Filer)</a></td>

Code:
Sub GetCIK()
  Sheets("wquery").Select
  Dim X As Long, LastRow As Long, OutputRow As Long, CellContent As String
  Const StartRow As Long = 1
  Const DataCol As String = "A"
  Const OutputSheet As String = "URLs"
  Const OutputCol As String = "B"
  LastRow = Sheets("wquery").Cells(Rows.Count, DataCol).End(xlUp).Row
  OutputRow = Worksheets(OutputSheet).Cells(Rows.Count, OutputCol).End(xlUp).Row
  For X = StartRow To LastRow
    If LCase(Sheets("wquery").Cells(X, DataCol).Value) Like "*getcompany&""CIK*&*" Then
      OutputRow = OutputRow + 1
      CellContent = Sheets("wquery").Cells(X, DataCol).Value
      Worksheets(OutputSheet).Cells(OutputRow, OutputCol).Value = Split(Mid(CellContent, InStr(1, CellContent, "getcompany&""CIK", vbTextCompare) + 15), """amp")(0)
    End If
  Next
 
Re: Help with the code

yes i did it, u reply on the old question, leave this one.replying on two threads with same question is annoying as well:)
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Re: Help with the code

HTML:
<td nowrap="nowrap">10-Q/A</td>

in above line u'r just using "nowrap", while it is
HTML:
"nowrap">
isn't making difference, i'm changing it in the code, but it is not working there
 
Upvote 0
Re: Help with the code

HTML:
10-Q/A

in above line u'r just using "nowrap", while it is
HTML:
"nowrap">
isn't making difference, i'm changing it in the code, but it is not working there

That doesn't matter. I've already accounted for that. It's just not there for the speed of the code.

At this stage, I think I will need to see your worksheet again.
Is it still the same worksheet?
 
Upvote 0
Re: Help with the code

.....
I can't believe I didn't see that.
Here you go
HTML:
Sub GetType()
    Dim X As Long, LastRow1 As Long, CellContent As String, lastRow&
    Dim pos1&, pos2&, OutputRow2&
    
    Const StartRow As Long = 1
    Const DataCol As String = "A"
    Const OutputSheet As String = "Filings"
    Const OutputCol2 As String = "C"
 
    lastRow = Sheets("wquery").Cells(Rows.Count, DataCol).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 "*""nowrap*" Then
            OutputRow2 = OutputRow2 + 1
            CellContent = Sheets("wquery").Cells(X, DataCol).Value
            pos1 = InStr(1, CellContent, """nowrap""")
            pos2 = InStr(1, CellContent, "</td>")
            If pos1 = 0 Or pos2 = 0 Then GoTo continue
            Worksheets(OutputSheet).Cells(OutputRow2, OutputCol2).Value = Mid(CellContent, pos1 + 9, pos2 - pos1 - 9)
        End If
continue:
    Next X
End Sub
 
Upvote 0
Re: Help with the code

it worked on your side? its not giving me error now, but not giving any results either, i changed my outputcol2 to "B"
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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