+ Reply to Thread
Results 1 to 9 of 9

need to run the entire list then post final result found or not found after.

Hybrid View

  1. #1
    Registered User
    Join Date
    10-11-2003
    Posts
    81

    need to run the entire list then post final result found or not found after.

    Ok so it cycles through top 6 ..

    just need it to "see" if certain words are in the top 5-6...

    Below does it.. but id' like it to cycle through all 5-6 ...then give the response yes its there or no its not found..

    Right now it responds..

    NOT FOUND
    NOT FOUND
    NOT FOUND
    YEP FOUND IT
    NOT FOUND
    NOT FOUND








    Sub ParseTable()
    Dim IE As InternetExplorer
    Dim htmldoc As MSHTML.IHTMLDocument 'Document object
    Dim eleColtr As MSHTML.IHTMLElementCollection 'Element collection for tr tags
    Dim eleColtd As MSHTML.IHTMLElementCollection 'Element collection for td tags
    Dim eleRow As MSHTML.IHTMLElement 'Row elements
    Dim eleCol As MSHTML.IHTMLElement 'Column elements
    Dim ieURL As String 'URL
    
    'Open InternetExplorer
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    
    'Navigate to webpage
    ieURL = "weblink"
    IE.Navigate ieURL
    'Wait
    Do While IE.Busy Or IE.ReadyState <> 4
        DoEvents
    Loop
    
    Set htmldoc = IE.Document 'Document webpage
    Set eleColtr = htmldoc.getElementsByClassName("class") 'Find all tr tags
    
    'This section populates Excel
    'For i = 1 To 5
    
    i = 0 'start with first value in tr collection
    For Each eleRow In eleColtr 'for each element in the tr collection
        Set eleColtd = htmldoc.getElementsByClassName("class")(i).getElementsByTagName("a") 'get all the td elements in that specific tr
       j = 0 'start with the first value in the td collection
        For Each eleCol In eleColtd 'for each element in the td collection
        
            If InStr(eleCol, "SOME TEXT TO FIND") = 0 Then                     '----------------NEW
            MsgBox "NOT FOUND"                                  '----------------NEW
            Else                                                '----------------NEW
            MsgBox "YEP FOUND IT"                               '----------------NEW
            End If                                              '----------------NEW
            
            
        Next eleCol 'rinse and repeat
        i = i + 1 'move to next element in td collection
        If i = 5 Then Exit Sub
    Next eleRow 'rinse and repeat
    
    
    
    End Sub
    Basically I dont want a "RINSE" and repeat more like remember and repeat and give the final result if anything was found in the 5-6 cycles.. at the very end.


    Thanks guys

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,866

    Re: need to run the entire list then post final result found or not found after.

    The po9st text is a bit foggy to me, but let me try to follow the thread title:

    Sub ParseTable()
    Dim IE As InternetExplorer
    Dim htmldoc As MSHTML.IHTMLDocument 'Document object
    Dim eleColtr As MSHTML.IHTMLElementCollection 'Element collection for tr tags
    Dim eleColtd As MSHTML.IHTMLElementCollection 'Element collection for td tags
    Dim eleRow As MSHTML.IHTMLElement 'Row elements
    Dim eleCol As MSHTML.IHTMLElement 'Column elements
    Dim ieURL As String 'URL
    
    'new
    dim finalresult as boolean
    finalresult = false
    
    'Open InternetExplorer
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    
    'Navigate to webpage
    ieURL = "weblink"
    IE.Navigate ieURL
    'Wait
    Do While IE.Busy Or IE.ReadyState <> 4
        DoEvents
    Loop
    
    Set htmldoc = IE.Document 'Document webpage
    Set eleColtr = htmldoc.getElementsByClassName("class") 'Find all tr tags
    
    'This section populates Excel
    'For i = 1 To 5
    
    i = 0 'start with first value in tr collection
    For Each eleRow In eleColtr 'for each element in the tr collection
        Set eleColtd = htmldoc.getElementsByClassName("class")(i).getElementsByTagName("a") 'get all the td elements in that specific tr
       j = 0 'start with the first value in the td collection
        For Each eleCol In eleColtd 'for each element in the td collection
        
    'change here
    
            If InStr(eleCol, "SOME TEXT TO FIND") <> 0 Then finalresult = true
    
        Next eleCol 'rinse and repeat
        i = i + 1 'move to next element in td collection
        If i = 5 Then Exit Sub
    Next eleRow 'rinse and repeat
    
    'after a loop completed - show result
    If finalresult then 
       MsgBox "NOT FOUND" 
    Else
       MsgBox "YEP FOUND IT"
    End If
            
    End Sub
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    10-11-2003
    Posts
    81

    Re: need to run the entire list then post final result found or not found after.

    ya I had another post, but it was answered then I was adding more to it ( the above ) so i figured its a new question and posted here sorry.

    Part one https://www.excelforum.com/excel-pro...-possible.html

  4. #4
    Registered User
    Join Date
    10-11-2003
    Posts
    81

    Re: need to run the entire list then post final result found or not found after.

    possibly exit sub stops too quick
    Last edited by 0o0o0; 06-05-2018 at 03:22 PM.

  5. #5
    Registered User
    Join Date
    10-11-2003
    Posts
    81

    Re: need to run the entire list then post final result found or not found after.

    nope does nothing. Exit sub? crosses it out? not sure.

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,866

    Re: need to run the entire list then post final result found or not found after.

    Try:
        i = i + 1 'move to next element in td collection
        If i = 5 Then 
          'after a loop completed - show result
          If finalresult then 
           MsgBox "NOT FOUND" 
          Else
           MsgBox "YEP FOUND IT"
          End If
          Exit Sub
        end if
    Next eleRow 'rinse and repeat
    
            
    End Sub

  7. #7
    Registered User
    Join Date
    10-11-2003
    Posts
    81

    Re: need to run the entire list then post final result found or not found after.

    I appreciate the help! but "Next eleRow 'rinse and repeat" just makes it do the rest again 5 then 5 then 5 then page done.

  8. #8
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,866

    Re: need to run the entire list then post final result found or not found after.

    Well, I probably misplaced messages, shall read:
        i = i + 1 'move to next element in td collection
        If i = 5 Then 
          'after a loop completed - show result
          If finalresult then 
           MsgBox "YEP FOUND IT" 
          Else
           MsgBox "NOT FOUND"
          End If
          Exit Sub
        end if
    Next eleRow 'rinse and repeat
    
            
    End Sub

    But as a matter of fact, I probably don't follow your idea: "but id' like it to cycle through all 5-6"

  9. #9
    Registered User
    Join Date
    10-11-2003
    Posts
    81

    Re: need to run the entire list then post final result found or not found after.

    not solved but marked as solved to end this thread.


    EDIT! actually we were missing eleCol... eleCol.innerText above so yes change the required and it is SOLVED
    Last edited by 0o0o0; 06-08-2018 at 02:21 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Found?, then delete entire rows. Not found end sub
    By Andrewstupendo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-21-2018, 01:56 PM
  2. Searching column 1 with data from 2 and reporting found or not found
    By San75 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-15-2016, 05:23 PM
  3. Search for value in a range and overwrite if found and create new if not found
    By mm671750 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-04-2016, 01:19 PM
  4. [SOLVED] delete entire row when value is found
    By 9599lorenzo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2015, 03:06 AM
  5. [SOLVED] delete entire row when value is found
    By 9599lorenzo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-13-2015, 06:47 PM
  6. Check for values in a table and if found add value found in column to left to list
    By robhargreaves in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-07-2013, 02:57 PM
  7. [SOLVED] Instead of showing #N/A and #REF!, i want the result show as "Not Found" and "Found"
    By DonnyLau in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-11-2013, 08:58 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1