+ Reply to Thread
Results 1 to 5 of 5

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...
    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

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

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

    You may want to post this into the VBA forum instead of the formulas and functions forum ...

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

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

    I meant to. It was a mistake.

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

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

    Quote Originally Posted by teylyn View Post
    You may want to post this into the VBA forum instead of the formulas and functions forum ...
    How do you delete threads here?

  5. #5
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

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

    Ask a moderator to move the thread.

+ 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. [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
  2. Replies: 1
    Last Post: 07-28-2014, 05:05 PM
  3. [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
  4. [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
  5. VBA code to seperate the data into different sheet based on column 4
    By acong in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-14-2013, 05:31 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