+ Reply to Thread
Results 1 to 1 of 1

Loop web data into new column on same sheet (Code included)

Hybrid View

  1. #1
    Registered User
    Join Date
    03-07-2015
    Location
    New York
    MS-Off Ver
    O365
    Posts
    56

    Loop web data into new column on same sheet (Code included)

    How can I modify this so it outputs the data to a new column on just 1 sheet? Right now, it's creating new sheets for each link. Would like to output to column 1, 2, 3 , 4, 5, etc...

    It's currently outputting to column 1 and 2 on each new sheet, which is fine. I just don't want to have 1000 sheets when I run the macro with 1000 links.

    Sub ImportWebData()
    
    J = 1
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    
    With Sheets("Input")
    
       RowCount = 1
       Do While .Range("A" & RowCount) <> ""
          CellName = .Range("A" & RowCount)
          URL = CellName
    
          'get web page
          IE.Navigate2 URL
          Do While IE.readyState <> 4 Or _
             IE.Busy = True
             DoEvents
          Loop
    
            Set DestSh = ActiveWorkbook.Worksheets.Add
            DestSh.Name = J
        
                Sheets(J).Select
                Cells.Select
                Selection.Delete Shift:=xlUp
                Range("A1").Select
                With ActiveSheet.QueryTables.Add(Connection:= _
                    "URL;" & CellName, Destination:=Range("$A$2"))
                    .Name = CellName
                    .FieldNames = True
                    .RowNumbers = False
                    .FillAdjacentFormulas = False
                    .PreserveFormatting = True
                    .RefreshOnFileOpen = False
                    .BackgroundQuery = True
                    .RefreshStyle = xlInsertDeleteCells
                    .SavePassword = False
                    .SaveData = True
                    .AdjustColumnWidth = True
                    .RefreshPeriod = 0
                    .WebSelectionType = xlEntirePage
                    .WebFormatting = xlWebFormattingNone
                    .WebPreFormattedTextToColumns = True
                    .WebConsecutiveDelimitersAsOne = True
                    .WebSingleBlockTextImport = False
                    .WebDisableDateRecognition = False
                    .WebDisableRedirections = False
                    .Refresh BackgroundQuery:=False
                End With
                
                J = J + 1
                
        Sheets("Input").Select
        RowCount = RowCount + 1
        
        Loop
        
    End With
    IE.Quit
    
    End Sub
    Last edited by S Thibault; 02-01-2016 at 12:39 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Loop web data into new column on same sheet (Code included)
    By S Thibault in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-01-2016, 09:16 PM
  2. [SOLVED] Loop not working properly - code included - help?
    By lealea1982 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-24-2015, 12:34 PM
  3. Replies: 1
    Last Post: 07-28-2014, 05:05 PM
  4. [SOLVED] save a sheet with code on workbook_open included
    By bulina2k in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-11-2014, 04:17 PM
  5. [SOLVED] VBA code to combine data from two different sheet columns and paste new sheet and column?
    By Chris* in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-16-2014, 03:15 AM
  6. [SOLVED] Loop till end of the sheet and loop back to first column again
    By smlim7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-29-2012, 10:03 AM
  7. Delete rows if column contains a blank code included
    By v3x0rg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2010, 10:01 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1