about getting info from two urls

muhittinemmi

New Member
Joined
Jun 20, 2023
Messages
19
VBA Code:
Sub Dovizal()

      Dim qt As QueryTable, url As String, key As String, gid As String
 
      If ActiveSheet.QueryTables.Count > 0 Then ActiveSheet.QueryTables(1).Delete
      ActiveSheet.Cells.Clear
 
      url = "https://canlidoviz.com/doviz-kurlari/enpara"
 
        
      Set qt = ActiveSheet.QueryTables.Add(Connection:="URL;" & url, _
      Destination:=Range("a2"))
 
 
      With qt
          .WebSelectionType = xlAllTables
          .WebFormatting = xlWebFormattingNone
          .Refresh
           MsgBox "Veriler Güncellendi"
          
      End With
    
  End Sub

The data in the first url is saved from a2.

How can I add the 2nd url to be saved from a15 onwards
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Try this version:
VBA Code:
Sub Dovizal2()
    Dim qt As QueryTable, url As String, key As String, gid As String
    Dim Url2 As String, I As Long

    For I = ActiveSheet.QueryTables.Count To 1 Step -1
        ActiveSheet.QueryTables(I).Delete
    Next I
    Columns("A:Z").ClearContents
 
    url = "https://canlidoviz.com/doviz-kurlari/enpara"
    Set qt = ActiveSheet.QueryTables.Add(Connection:="URL;" & url, _
    Destination:=Range("a2"))
   
   
    With qt
        .WebSelectionType = xlAllTables
        .WebFormatting = xlWebFormattingNone
        .BackgroundQuery = False
        .Refresh
    End With
'
'second query:
    Url2 = "https://canlidoviz.com/doviz-kurlari/enpara"
    Set qt = ActiveSheet.QueryTables.Add(Connection:="URL;" & Url2, _
    Destination:=Range("A2").Offset(1 + Range(Range("A2").QueryTable.Name).Rows.Count))
    With qt
        .WebSelectionType = xlAllTables
        .WebFormatting = xlWebFormattingNone
        .BackgroundQuery = False
        .Refresh
    End With
   
    MsgBox "Veriler Güncellendii"
   
  End Sub
You will note that the macro doesn't set the "destination" of the second query "from a15 onwards", because the first query extracts (in my testing) up to line 23, and Excel doesn't accept that the second query overlaps with the first one; so the "destination" for the second query is set after the end of the first one

Try...
 
Upvote 0
Solution

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

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