Clicking a button on a website

Jakarius31

New Member
Joined
Jan 6, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm trying to write a macro to open a website and carry out a search for the location within a Cell in my workbook.

The website is the British Geological Survey. Geology of Britain viewer | British Geological Survey (BGS)

Typical when I open the website I have to click the button near the top right corner "Go to Location", then type in the postcode, hit "Search for location", then i would also like to press the button on the left "Superficial Only". I'm trying to automate this process.

So far I have manged to get the postcode as a string from the address in Excel, and open the website. But I'm struggling with the next parts.

Can someone advise as to how to click the buttons?

My code so far is:

VBA Code:
Sub BGSwebsite()

    Dim Address As String
    Address = ActiveCell

    LResult = Right(Address, 8)

    MsgBox LResult

    Const Url$ = "http://mapapps.bgs.ac.uk/geologyofbritain/home.html"

    Dim ie As Object
    Set ie = CreateObject("InternetExplorer.Application")

    With ie

    .navigate Url
.Visible = True

Do
DoEvents
Loop Until ie.ReadyState = 4

End Sub

Thanks in advance for any advice!

Jak
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi, I should note that I've added the "End With" line of code after the "loop".
 
Upvote 0

Forum statistics

Threads
1,215,679
Messages
6,126,186
Members
449,296
Latest member
tinneytwin

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