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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi, I should note that I've added the "End With" line of code after the "loop".
 
Upvote 0

Forum statistics

Threads
1,223,920
Messages
6,175,373
Members
452,638
Latest member
Oluwabukunmi

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