Editing Recorded Macro - using Data From Web

krishhi

Active Member
Joined
Sep 8, 2008
Messages
328
Hello,

I have recorded a macro and I need to loop the same macro with different Web address. I tried myself but I failed.

Please Check the excel file for what i wanted to do.

Code:
http://www.4shared.com/file/DPcUMGz9/Office_Project.html

Thanks,

Krrish
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hello Krishhi,

I've solved your problem:

Code:
Sub Macro2()

'
Dim Loper As String
Dim lr As Long

sr = Sheets("Sheet2").UsedRange.Rows.Count


For i = 1 To sr

lr = Sheets("Sheet1").UsedRange.Rows.Count
p = "URL;" & Sheets("Sheet2").Range("A" & i).Value
lr = lr + 4
Loper = "A" & lr
      
        
 With Sheets("Sheet1").QueryTables.Add(Connection:=p, Destination:=Range(Loper))
        
        
       ' .Name = "searchResults.jsp?thingname=&1=FL&2=+Miami&zip=&radius=60&ratedonly=1"
       
        .Name = Sheets("Sheet2").Range("d" & i).Value
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = False
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingAll
        .WebTables = "8"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
        

    End With

Next
End Sub

What I did is just add the q value directly into the function and used a string variable to determine to wich cell he needs to copy to


Jos
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

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