+ Reply to Thread
Results 1 to 15 of 15

IF Function that references web page

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-07-2012
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    172

    IF Function that references web page

    change this slgihtly so some more people may be able to answer:

    How can I create an IF function such that if

    http://www.investegate.co.uk/Advance...qsContains=rkh

    contains the word 'specified', the cell colour changes to green
    Last edited by spursrule68; 06-01-2012 at 07:04 AM.

  2. #2
    Forum Contributor
    Join Date
    02-07-2012
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    172

    Re: Complex Cell Formatting based on web data presence

    see updated above
    Last edited by spursrule68; 06-01-2012 at 05:55 AM.

  3. #3
    Forum Contributor
    Join Date
    02-07-2012
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    172

    Re: IF Function that references web page

    alternatively a piece of vba code that

    1. references the web page
    2. then searches for the word specified
    3. then changes the colour of cell A1 based on the result.

    This must be possible, surely?

  4. #4
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: IF Function that references web page

    You mean the word 'specified' in the URL or in the body of the webpage?

  5. #5
    Forum Contributor
    Join Date
    02-07-2012
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    172

    Re: IF Function that references web page

    body of the webpage, alternatively it could be based on whether a table is present ont he webpage or not. either will do

  6. #6
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: IF Function that references web page

    If you want to make use of your alternative, you can add something like this after the full load of IE

    Set htmlDoc = IE.Document                                               
     Set TableColl = htmlDoc.getElementsByTagname("TABLE")
         For Each htmlTable In TableColl
            If htmlTable.Name = "specified" Then
                 'paint green
            End If
         Next htmlTable
     Set TableColl = nothing
    Set htmlDoc = nothing

  7. #7
    Forum Contributor
    Join Date
    02-07-2012
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    172

    Re: IF Function that references web page

    I ran the macro and nothing happened. i have attached my Book2.xlsworksheet so its easier for you to see.

  8. #8
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: IF Function that references web page

    Put your URL in cell A1 and your search word in B1.
    E.G. try 'specified' in cell B1 and try again with the word 'type'

    Sub main()
    
    'Initiate IE
        Set IE = CreateObject("InternetExplorer.application")
        'IE.Visible = True
    'Navigate
        IE.Navigate Range("A1").Value
    'Loop unitl ie page is fully loaded
        Do Until IE.READYSTATE = 4
        Loop
    'Paint Green if word is found in body
        If InStr(IE.Document.body.innertext, Range("B1").Value) = 0 Then
            'nothing
        Else
            With Range("A1").Interior
                .Pattern = xlSolid
                .PatternColorIndex = xlAutomatic
                .Color = 5296274
                .TintAndShade = 0
                .PatternTintAndShade = 0
            End With
        End If
    'Close and release
        IE.Quit
        Set IE = Nothing
    
    End Sub

  9. #9
    Forum Contributor
    Join Date
    02-07-2012
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    172

    Re: IF Function that references web page

    Hi rkey

    I have pasted the code into worksheet 1 of the vba and have put specified in B1 and the URl in A1

    Slightly confused as to what i need to do next.

    much thanks for your help so far by the way, i'll be sure to rep you after

  10. #10
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: IF Function that references web page

    Press alt+f8 and select the macro Main to run it.

  11. #11
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: IF Function that references web page

    I believe the word 'specifíed' is not present in the body of the URL you posted in your initial post.
    Have you tried running it with the word 'type'?

  12. #12
    Forum Contributor
    Join Date
    02-07-2012
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    172

    Re: IF Function that references web page

    Ah of course! Many thanks!

    repped and solve

  13. #13
    Forum Contributor
    Join Date
    02-07-2012
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    172

    Re: IF Function that references web page

    Quote Originally Posted by rkey View Post
    I believe the word 'specifíed' is not present in the body of the URL you posted in your initial post.
    Have you tried running it with the word 'type'?
    out of interest rkey. How would you change the vba code so that the macro could perform the same function, but check for a list of URLS rather than just one, but for the same word?

  14. #14
    Forum Contributor
    Join Date
    02-07-2012
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    172

    Re: IF Function that references web page

    I am also getting a sign come up saying ' object doesnt support this property or method' as soon as i change the suffix of the link name from rkh to csr for example

  15. #15
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: IF Function that references web page

    Check this for a range of URL's

    Search IEpage for perticulair word.xlsm

    I don't get the message when changing the URL (got them both in this attachement).
    You got an example of it perhaps?

    BTW comment "IE.Visible = True" if you don't want the IE window visible

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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