PDA

View Full Version : Get live changes of a number on a webpage



MiRaN1337
12-17-2020, 02:38 PM
Dears,

I hope each and every one of you is having a good day

So what I'm trying to do is: There is a webpage that has some numbers that are continuously changing, I want a cell of my excel sheet to get live updates of one of the numbers on the webpage.

What I have so far: I wrote a VBA code (First time VBA, kind of expert in Java), that gets the number and sets it inside the active cell without any problem. But, what I want it to do is keep getting live updates of the number on the webpage.

What I tried to get live updates: I tried to use an infinite loop but it makes my Excel window unresponsive. I also tried Application.OnTime but I failed to find-out how to pass a parameter to it

Here's my excel file, you can see the VBA code: 27588

Any help is appreciated
Best regards

DanWall
12-23-2020, 11:58 PM
Here's my excel file, you can see the VBA code: 27588

Any help is appreciated
Best regards[/QUOTE]

Hi. If that's the data that you want, and that's the website that you want to get it from, then I'd recommend skipping VBA/IE altogether and just letting Excel handle it for you through a simple data query (Data Tab -> Get Data -> Get Data from Web). This will source the data for you and deposit it onto a spreadsheet as per the picture below. It also runs continuous updates of the data for you.
It's a lot quicker and more efficient than using VBA to resurrect additional instances of IE every two seconds to go find out the data for you!!

Separately, as regards your code, you were on the right track with your Application.Ontime approach, and with the parameters you were using, except for two points:


Application.OnTime Now + TimeValue("00:00:02"), "'RunEveryOneSecond " & IE & "'"

Here, you were trying to concatenate a string with an object (IE) and this was never going to work.

I wrote a much longer post setting out my comments, and attaching a screen capture, but the system rejected it and deleted all my text in the post. Having lost my sense of humour with this system, and needing to go to sleep, I'll have to leave it here, in hopes that one of the admins (benevolently) permits me to post this on the site. Let me know if you need any help with the above and I will try again tomorrow.

MiRaN1337
12-24-2020, 10:23 AM
Hello DanWall,

I appreciate you replying to my question.

The reason why I didn't use the data query method is because it doesn't even work with that website, the reason why is the data that I'm trying to get is not inside a table so the web query method does not detect it.

As regards my code, you did tell me why my code was not going to work, but you didn't tell me what are the changes that I need to do to get it to work.

Best regards.

DanWall
05-12-2021, 09:02 AM
Hello DanWall,<br>
<br>
I appreciate you replying to my question.<br>
<br>
The reason why I didn't use the data query method is because it doesn't even work with that website, the reason why is the data that I'm trying to get is not inside a table so the web query method does not detect it.<br>
<br>
As regards my code, you did tell me why my code was not going to work, but you didn't tell me what are the changes that I need to do to get it to work.<br>
<br>
Best regards.<br>Hi. Apologies for the very belated response - I thought I had replied to this, but I guess not. From memory, I tried to post the info again on Xmas day, but couldn't - and I guess it slipped my mind afterwards. Looking at it again just now, I suspect I didn't want to spend too much time on it because it is accessible through the data query method. I remember checking it then, and I've just checked it again now - it's there. Using the data query method, it returns three tables (Table 0, 1 and 2). The particular information you want is identifiable from the class name in your code - which is precisely the same data point as that which is contained in Table 0. I am looking at it refresh on my spreadsheet right now. You probably don't need it anymore, but let me know if you do.

AND I just tried to send the screen captures again, and it won't keeps on telling me I can't send URLs (I'm not) - I'm sick of it. Look, it's doable - I've done four times.

MiRaN1337
05-13-2021, 07:08 AM
<br>Hi. Apologies for the very belated response - I thought I had replied to this, but I guess not. From memory, I tried to post the info again on Xmas day, but couldn't - and I guess it slipped my mind afterwards. Looking at it again just now, I suspect I didn't want to spend too much time on it because it is accessible through the data query method. I remember checking it then, and I've just checked it again now - it's there. Using the data query method, it returns three tables (Table 0, 1 and 2). The particular information you want is identifiable from the class name in your code - which is precisely the same data point as that which is contained in Table 0. I am looking at it refresh on my spreadsheet right now. You probably don't need it anymore, but let me know if you do.

AND I just tried to send the screen captures again, and it won't keeps on telling me I can't send URLs (I'm not) - I'm sick of it. Look, it's doable - I've done four times.

No problem brother, you still replied so it is not a big deal, I would love to know how did you do it, you can PM me if you want

Best regards