Results 1 to 4 of 4

Adding column to an array

Threaded View

ChipsSlave Adding column to an array 07-20-2017, 02:07 PM
AB33 Re: Adding column to an array 07-20-2017, 04:22 PM
ChipsSlave The website contains table... 07-20-2017, 04:35 PM
AB33 Re: Adding column to an array 07-21-2017, 05:22 AM
  1. #1
    Forum Contributor
    Join Date
    09-21-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    131

    Adding column to an array

    Hello all,

    I have got a VBA code which pulls data from a table on website. This data you can find on sheet called Sheet1. But my desired table i want it to look like is visualised in sheet called Desired. Would it be possible to add two variables to an array from website? The variables I want to add are nowDate, nowTime, cat, website.

    Sub DolphinFitness()
     Dim oHtml As HTMLDocument
     Dim oElement As Object
     Dim a, x, i As Long, ii As Long
     Dim nowDate, nowTime As Date
     Dim cat, website As String
     
     nowDate = Format(Now(), "dd/mm/yyyy", vbSunday)
     nowTime = Format(Now(), "hh:mm", vbSunday)
     website = "DolphinFitness"
     cat = "protein-isolate"
     
     'Needs a Reference.
     'Go to Tools > Reference > Search for Microsoft HTML Object Library > tick the checkbox > OK
     Set oHtml = New HTMLDocument
     
     With CreateObject("WINHTTP.WinHTTPRequest.5.1")
        .Open "GET", "http://www.dolphinfitness.co.uk/en/protein-isolate", False
        .send
        oHtml.body.innerHTML = .responseText
        Debug.Print
     End With
    
     ReDim a(1 To 100000, 1 To 5)
     For Each oElement In oHtml.getElementsByClassName("snapshot")
        i = i + 1
        x = Split(oElement.outerText, vbCr)
        For ii = 1 To UBound(x)
            a(i, ii) = Trim$(x(ii))
        Next
        
     Next oElement
     Sheets("Sheet1").Cells(2, 1).Resize(i, 5) = a
     
     '' remove line breaks
         Dim MyRange As Range
        Application.ScreenUpdating = False
        Application.Calculation = xlCalculationManual
     
        For Each MyRange In ActiveSheet.UsedRange
            If 0 < InStr(MyRange, Chr(10)) Then
                MyRange = Replace(MyRange, Chr(10), "")
            End If
        Next
        
    '' remove sterling sign
        ActiveSheet.Range("C:C").Replace What:="£", Replacement:="", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False
     
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Finding a column via header search and then adding everything in it into an array.
    By Scoobster_doo in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-22-2017, 09:58 AM
  2. Adding Column to Table with Array Formula
    By eliasc in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-10-2016, 03:48 PM
  3. [SOLVED] Adding another column to existing table with array formula
    By eliasc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-08-2016, 09:00 AM
  4. [SOLVED] 2 Column Lookup with 6 Column array Col index number is Varies Within Entire Array
    By Weasyb in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-05-2015, 12:54 PM
  5. [SOLVED] Adding to a new variable array from an existing array
    By Aussiexile in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-17-2014, 12:08 AM
  6. [SOLVED] Adding an extra column in a 2D array
    By j_Southern in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-24-2014, 07:27 AM
  7. Adding an array of Dates to an Array of Times.
    By cummins in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-25-2011, 09:12 PM

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