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
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.
see updated above
Last edited by spursrule68; 06-01-2012 at 05:55 AM.
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?
You mean the word 'specified' in the URL or in the body of the webpage?
body of the webpage, alternatively it could be based on whether a table is present ont he webpage or not. either will do
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
I ran the macro and nothing happened. i have attached my Book2.xlsworksheet so its easier for you to see.
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
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
Press alt+f8 and select the macro Main to run it.
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'?
Ah of course! Many thanks!
repped and solve![]()
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
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks