Consulting

Results 1 to 5 of 5

Thread: Breakapart innerhtml in Excel

  1. #1
    VBAX Regular
    Joined
    Nov 2006
    Posts
    19
    Location

    Breakapart innerhtml in Excel

    Hi,

    I have captured data from a table in IE and have it going to range"a1"

    Set mytable = IeApp.document.getElementById("maindetail")
    Sheets("sheet1").Activate
    Sheets("sheet1").Range("a1").Value = IeApp.document.getElementById("maindetail").innerHTML
    I'd like to "parse" this data so that the html tags are removed and each item is placed in its own cell (a1, a2, a3 etc.

    Thanks

  2. #2
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    A little bit more info would be welcome. Maybe rest of your code so at least we know what kind of site (or the url) you want to parse to excel. Is the html-page formatted as a table or not ? Is there more than one table on this page. Can we look at div-tags ? Or is there a link on the page itself to parse it to excel ?

    How is the info placed in A1 ? Are they seperated by a special character (, or " or something else ?) ?

    Charlize

  3. #3
    VBAX Regular
    Joined
    Nov 2006
    Posts
    19
    Location
    The url is corporate and I cannot post it. I actually was able to use innertext instead of innerhtml. Now all tags are removed but each item i need in individual cells are seperated by char(10). That should be an easy fix.

    Thanks

  4. #4
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    If you are going to cross post at least provide a link http://www.ozgrid.com/forum/showthread.php?t=60994.

  5. #5
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    jhize,

    Sorry, it's still too early for me to try any coding, but. . .
    Now this AIN'T code:

    As I understand it you have the string
    wordChar(10)wordChar(10)wordChar(10)word

    [VBA]
    Build a loop
    i as LoopCounter
    While StringInActiveCell <> ""
    IF find Char(10) '[means two or more words]
    Let l = location first Char(10)
    '[Put word(i) in appropriate column]
    ActiveCell.Offset(0, i) = StringLeft to l
    String = l to StringRight '[take THAT word out of String]
    Else Only one word
    ActiveCell.Offset(0, i) = String
    Endif
    Next i
    End Loop
    '[put start of word list back in activecell]
    Range(Offset(0, 1):Offset(0, i)).Copy destination:= ActiveCell
    '
    '
    '

    [/VBA]
    Hoping this brings your Muse,
    SamT


    Where's my coffee?!?!?!

Posting Permissions

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