+ Reply to Thread
Results 1 to 20 of 20

Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

  1. #1
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,101

    Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    Hello,

    First of all, thank you to Norie and Sean Thomas who'd helped me with solved my first problem.

    After able to find the number of rows, I'm facing with another difficulty.

    How do I get the specific row and column value in the table?

    I have attached 3 png files where, the 1st shows the "unexpanded" records that were found.
    The 2nd attach is the expand of the '1st record' with its items, where the items are actually the header columns with it's values in the intranet.
    The 3rd attach is the expand of the item (in the example, is the item no.15)

    My question is, how do I go to each record of the given column and take the value?

    Given the attach example, how do I write in VBA to give me the value 'Hallett Crescent' from the "recordIndex = 0' (1st record) from item/row 15?
    Attached Images Attached Images

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    Hi,
    after you have got your collection of tables you can then use the following if you know which table, row & cell you want

    Please Login or Register  to view this content.
    this will retrieve the data from the 3rd table, 2nd Row, 15th Column
    tables work from 0. the first table, row or column(cell) is always 0
    that's why if you use the length attribute in a loop you will get an error as you need to deduct 1.
    ie for a table of 10 columns x 5 rows.
    rows.length = 5
    cells.length = 10
    but the index used will be
    rows 0 - 4
    cells 0 - 10
    therefore if you tried to find rows(rows.length).innertext you would get an error. But rows(rows.length-1).innertext will be correct.

    ie
    Please Login or Register  to view this content.
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    You can also use nested For Eachs to get the entire table.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  4. #4
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,101

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    Thank you Sean and Norie for the help.

    Norie, to be honest, I have not tried your code yet, reason being, I prefer Sean's code, as it's easier for me to understand (I'm not a programmer) and the idea and logic is similar to what I was trying to do.

    That being said, Sean and Norie, I've tried to use Sean's code and modified a little, and it's giving me an error message which is

    Run-time error '91':
    Object variable or With block variable not set.

    Please Login or Register  to view this content.
    I tried to look at each String values, and they all give me blank (to be precise "")

  5. #5
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    What line does it error on?

  6. #6
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,101

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    Quote Originally Posted by Sean Thomas View Post
    What line does it error on?
    It errors right on

    Please Login or Register  to view this content.
    I would assume it'll error on other string as well

  7. #7
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    hi, your 2nd part was not in the loop so it would not recognise the correct recordcollections as it will be using the last i used
    Please Login or Register  to view this content.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    What are you actually trying to do?

    By the way, what is it you don't understand in the code I posted?

    I thought it was quite straightforward - get table, get data from table by looping through the rows and columns (cells) of the table.
    Last edited by Norie; 01-08-2014 at 11:21 AM.

  9. #9
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,101

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    Sean,

    Thank you for your help!

    Interestingly enough, I still receive the same error message, and it's still on the 1st string.

    Please Login or Register  to view this content.
    WITH THE EXCEPTION that, my string values are now have values, instead of "" (empty).

  10. #10
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,101

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    Quote Originally Posted by Norie View Post
    What are you actually trying to do?

    By the way, what is it you don't understand in the code I posted?

    I thought it was quite straightforward - get table, get data from table by looping through the rows and columns (cells) of the table.
    Apologies Norie for not able to understand your code, even though it's a very straightforward one.

    What I tried to do is

    1. Put the ID from Excel to IE.
    2. If found, check how many records
    3. If no record found, move to the next input excel value and copy it to IE (back to step 1)
    4. If only 1 record found, then, go to excel and input the value from IE from header/item no 45 for example.
    5. If multiple records found, then check if value from header/item no 7 is "Disconnect" and header/item no 8 is "Completed".
    5.1 If it's true, then do copy and paste the values from other string variables that have been created and put it to excel
    5.2 if it's false, then do something else.

    I hope this could clarify your questions norie =)

  11. #11
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    it might be because your are looping through the tables.
    it works when you find the table you want but will still be passing the original i to the rest of the tables after.

    try putting the 2nd part within the if statement
    Please Login or Register  to view this content.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    The looping isn't quite right, you should have a loop for finding the table with the records and then a separate loop to go through the rows/records of that table, if required.

    Please Login or Register  to view this content.
    Last edited by Norie; 01-08-2014 at 11:54 AM.

  13. #13
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    Nice code Norie,
    thats the smarter way to do it.
    I didnt really have the time to address it like you did, im working at the moment and shouldnt even be on here. LOL

  14. #14
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,101

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    Norie,

    Tried to use your code there, but why is it that when I tried to hold on part of the code, i.e. putting a msgbox after the End Select to let me know what's the value for i.e. strCircuit, it's not showing me anything?

  15. #15
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,101

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    It's ok...I found the "error"...it's because you have the "Exit Sub" instead of "Exit For".

    Thank you once again guys for your help.

    Reps up to both of you! Please check! =D

  16. #16
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    Perhaps the message box was never reached.

    Try putting a break point in the code (F9) at the start of the Select Case.

    You might also want to put one here,
    Please Login or Register  to view this content.
    here,
    Please Login or Register  to view this content.
    perhaps here too.
    Please Login or Register  to view this content.

  17. #17
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    dluhut

    I edited and changed the Exit Sub to Exit For.

  18. #18
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,101

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    Quote Originally Posted by Norie View Post
    dluhut

    I edited and changed the Exit Sub to Exit For.
    Yes, I noticed that too.

    Also, I think it's supposed to be

    Please Login or Register  to view this content.

  19. #19
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    Yep, that's right.

    Need to start checking my code I suppose.

  20. #20
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,101

    Re: Excel VBA with Internet Explorer (Cont'd) - Getting the row and column no.

    Quote Originally Posted by Norie View Post
    Yep, that's right.

    Need to start checking my code I suppose.
    Well, at least it's working now!

    Thanks to you and Sean =D

+ 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. Using Excel with Internet Explorer
    By cbanks in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-16-2007, 05:37 PM
  2. [SOLVED] Excel In Internet Explorer
    By John Boggins in forum Excel General
    Replies: 2
    Last Post: 12-22-2005, 10:21 AM
  3. Excel/VBA/Internet Explorer
    By Alex in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-22-2005, 01:09 PM
  4. [SOLVED] opening Excel from Internet Explorer
    By Jeff in forum Excel General
    Replies: 2
    Last Post: 11-13-2005, 08:40 PM
  5. [SOLVED] Internet Explorer & Excel
    By David in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-04-2005, 05:06 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