Consulting

Results 1 to 6 of 6

Thread: Get Msgbox in a table

  1. #1

    Get Msgbox in a table

    Hello,

    How can I get this messagebox in a table in Active sheet.

    ergebnis = Chr(9) & Chr(9)
    ergebnis = ergebnis & x.getElementsByTagName("th")(0).getElementsByTagName("img")(0).getAttribute ("alt")
    ergebnis = ergebnis & Chr(9)
    ergebnis = ergebnis & x.getElementsByTagName("th")(2).getElementsByTagName("img")(0).getAttribute ("alt")

    ergebnis = ergebnis & Chr(13) 'Zeilenumbruch

    Set y = knotenTabelle.getElementsByClassName("Alpha")

    For Each y In z
    ergebnis = ergebnis & y.getElementsByTagName("th")(0).innerText
    If Len(y.getElementsByTagName("th")(0).innerText) > 9 Then
    ergebnis = ergebnis & Chr(9) 'Ein Tab
    Else
    ergebnis = ergebnis & Chr(9) & Chr(9) 'Zwei Tabs
    End If
    ergebnis = ergebnis & y.getElementsByTagName("td")(0).innerText
    ergebnis = ergebnis & Chr(9) & Chr(9) 'Zwei Tabs
    ergebnis = ergebnis & y.getElementsByTagName("td")(1).innerText
    ergebnis = ergebnis & Chr(13) 'Zeilenumbruch
    Next z
    End If
    MsgBox ergebnis
    End Sub

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    try, instead of MsgBox ergebnis this:
    Set Destn = Range("L3") 'or wherever you choose top left to be
    xx = Split(ergebnis, Chr(13))
    For zz = 0 To UBound(xx)
      p = Split(xx(zz), Chr(9))
      Destn.Offset(zz).Resize(, UBound(p) + 1).Value = p
    Next zz
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    Something is wrong with it.
    Can you please have a look?

    Dim xx
    Dim p
    Dim zz As Long

    Destn.Offset(zz).Resize(, UBound(p) + 1).Value = p --> 1004 application-defined or object-defined

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    I've no idea what ends up being in ergebnis so it's difficult to reproduce your error (I can't).
    What is p when you get the error? Is it an array?
    You can test this:
    Instead of:
    Destn.Offset(zz).Resize(, UBound(p) + 1).Value = p
    try:
    If UBound(p) > -1 Then Destn.Offset(zz).Resize(, UBound(p) + 1).Value = p

    Perhaps attach a workbook where you've managed to get a typical value in ergebnis?
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  5. #5
    Hello p45cal,

    thanks for your help. Ergebnis looks like the example.jpg

    So prefer something like this:

    Range("H2") = x.getElementsByTagName("th")(0).getElementsByTagName("img")(0).getAttribute ("alt")
    Range("J2" = x.getElementsByTagName("th")(2).getElementsByTagName("img")(0).getAttribute ("alt")


    Set y = knotenTabelle.getElementsByClassName("Alpha")
    For Each y In z
    ergebnis = ergebnis & y.getElementsByTagName("th")(0).innerText
    If Len(y.getElementsByTagName("th")(0).innerText) > 9 Then
    ergebnis = ergebnis & Chr(9) 'Ein Tab
    Else
    ergebnis = ergebnis & Chr(9) & Chr(9) 'Zwei Tabs
    End If
    ergebnis = ergebnis & y.getElementsByTagName("td")(0).innerText
    ergebnis = ergebnis & Chr(9) & Chr(9) 'Zwei Tabs
    ergebnis = ergebnis & y.getElementsByTagName("td")(1).innerText
    ergebnis = ergebnis & Chr(13) 'Zeilenumbruch
    Next z
    End If
    MsgBox ergebnis
    End Sub

    But I have some problems with the loop.
    Attached Images Attached Images

  6. #6
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    There's just not enough information to offer a solution for this one. If ergebnis contains what's in the picture, it's not very useful is it?
    We need to know what x is - I realise it's likely to be an html document, or part of one, but these tiny snippets of code are not enough.
    Are you web scraping? Is the site you're scraping publicly available? If so, attach a workbook with more code and urls.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

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