VBA, Request Send, IN Table Search for href & click, Table Search for name & Copy name & result to Excel

Mekee

New Member
Joined
Jun 28, 2017
Messages
1
Hello, hope for help!


I have a VBA script that is functional but I'd like to make it a bit better.

This is a question for the folling page:
https://www.e-control.at/konsumenten/service-und-beratung/toolbox/tarifkalkulator


1. The query of the first page works: postcode = 1010 & kwh consumption = 1000Then send

2.
The second page is not the optimal page I would like to query. On this page I would like to query the table in column 1. If the query finds a link click on this link. (loop this)

3. On page 3, I would then copy from the table predefined names of the lines of the result.
The predefined names are in Excel in table A1 of a row.The result should be under the supplier's name. The supplier name should be copied from the table from the web. The product of the supplier should be placed under the supplier name in the same column.(loop this)

(please loop to page 2.)

Info:

The string from the link after the? Is for me unfortunately too complicated, since this consists of nothing but variable. The structure of the homepage is also not exactly programmed according to standard html. This page is my opinion in XHTML.Perhaps this information helps.


My code is currently:

Code:
[/COLOR][/FONT]
[FONT=arial][COLOR=#212121]Option ExplicitSub TableExample()    Dim IE As Object    Dim doc As Object    Dim strURL As String    Dim I As Integer        strURL = "https://www.e-control.at/konsumenten/service-und-beratung/toolbox/tarifkalkulator" ' replace with URL of your choice                    Set IE = CreateObject("InternetExplorer.Application")    With IE         .Visible = True                .navigate strURL        Do Until .readyState = 4: DoEvents: Loop            Do While .Busy: DoEvents: Loop            'For i = 0 To 1  Application.wait (Now + TimeValue("0:00:10"))  'Application.Speech.Speak ("Daten werden Geladen" & Time)'Next i                         IE.document.getElementById("_tk_portlet_WAR_tk_:tk-form-start:tk-index-search-form-zip").Value = _      Sheets("Tarife e-control").Range("A1").Value     IE.document.getElementById("_tk_portlet_WAR_tk_:tk-form-start:tk-index-search-form-electricity-consumption").Value = _      Sheets("Tarife e-control").Range("A2").Value     'click the 'go' button    IE.document.getElementById("_tk_portlet_WAR_tk_:tk-form-start:tk-index-search-form-search-button").Click           Do Until .readyState = 4: DoEvents: Loop            Do While .Busy: DoEvents: Loop                Set doc = IE.document                'For i = 0 To 1  Application.wait (Now + TimeValue("0:00:30"))  'Application.Speech.Speak ("Daten werden geladen" & Time)  'Next i                '.Quit                                GetAllTables doc            End With                    End Sub        Sub GetAllTables(doc As Object)                             ' get all the tables from a webpage document, doc, and put them in a new worksheet                        Dim ws As Worksheet            Dim rng As Range            Dim tbl As Object            Dim rw As Object            Dim cl As Object            Dim tabno As Long            Dim nextrow As Long            Dim I As Long            Dim xl As String            Dim y As Integer                                                             Set ws = Sheets("Stocks")                          For Each tbl In doc.getElementsByTagName("Table")                                                                   tabno = tabno + 1                nextrow = nextrow + 1                Set rng = ws.Range("B" & nextrow)                rng.Offset(, -1) = "Table " & tabno                For Each rw In tbl.Rows                    For Each cl In rw.Cells                                           rng.Value = cl.outerText                       Set rng = rng.Offset(, 1)                        I = I + 1                                           Next cl                    nextrow = nextrow + 1                    Set rng = rng.Offset(1, -I)                    I = 0                Next rw            Next tbl                         ws.Cells.ClearFormats        End Sub[/COLOR][/FONT][FONT=arial][COLOR=#212121]

thx for help!
****** id="cke_pastebin" style="position: absolute; top: 0px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">The string from the link after the? Is for me unfortunately too complicated, since this consists of nothing but variable. The structure of the homepage is also not exactly programmed according to standard html. This page is my opinion in XHTML.Perhaps this information helps.

</body>****** id="cke_pastebin" style="position: absolute; top: 0px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">I have a VBA script that is functional but I'd like to make it a bit better.I have a VBA script that is functional but I'd like to make it a bit better.</body>
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

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