+ Reply to Thread
Results 1 to 33 of 33

Getting Youtube Video View Count

  1. #1
    Registered User
    Join Date
    11-22-2013
    Location
    derby
    MS-Off Ver
    Excel 2013
    Posts
    8

    Getting Youtube Video View Count

    Evening all.

    I have a question that I'm not even sure is possible. I have seen similar or the same questions asked but I don't understand the answer or don't think its what i need so here goes.

    Lets say I have a list in row a of links that link to various different YouTube videos.
    These videos or channels aren't owned by me.
    Can i use a script that will visit each page and pull the view count from each video and put it in row b?

    Many thanks in advance.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Getting Youtube Video View Count

    Hello jtb1979,

    Welcome to the Forum!

    Here is a macro that takes the URL as it's argument. It will return the count for the video.
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 11-22-2013 at 06:51 PM.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    11-22-2013
    Location
    derby
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Getting Youtube Video View Count

    Thanks that basically works.

    Though I have a problem.

    Because its a function it is always checking the links provided, meaning that Excel is crashing every minute due to it doing a lot of processing.
    Is there a way I can only run it once, or stop it from constantly checking the links?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Getting Youtube Video View Count

    Hello jtb1979,

    Can you post an example of the data layout and how you are using the macro?

  5. #5
    Registered User
    Join Date
    11-22-2013
    Location
    derby
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Getting Youtube Video View Count

    test.xlsm

    That's very basic.

    In my actual sheet I have (so far) 40 different videos I'm checking. The view counts are constantly being checked (well at least once a minute)

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Getting Youtube Video View Count

    Hello jtb1979,

    I don't see in your workbook where the view counts are being checked each minute. Unless you are manually editing each cell, the UDF will not update the cell when the sheet is calculated.

  7. #7
    Registered User
    Join Date
    11-22-2013
    Location
    derby
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Getting Youtube Video View Count

    So if I'm sorting a group of data that contains the function then it will update?

    Because i did think that may be it.

  8. #8
    Registered User
    Join Date
    03-03-2014
    Location
    BLUEWORLD
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Getting Youtube Video View Count

    have been looking for this. thank you.
    Last edited by silverrain; 03-03-2014 at 09:07 AM.

  9. #9
    Registered User
    Join Date
    03-03-2014
    Location
    BLUEWORLD
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Getting Youtube Video View Count

    I have been trying to find the way to refresh data but I don't know VB and macro so would you mind helping me about it?

  10. #10
    Registered User
    Join Date
    10-27-2014
    Location
    London, England
    MS-Off Ver
    2003
    Posts
    8

    Re: Getting Youtube Video View Count

    Hello, I took your code above and put it into visual basic editor in excel. I don't know what to do next. I don't know much about VB, please help.

    I want to take up to 50 links in an excel and get their view counts.

    - Could I make this work? https://halgatewood.com/php-get-tota...-youtube-views
    Last edited by ownifier; 07-06-2015 at 12:44 PM. Reason: new info

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Getting Youtube Video View Count

    Hello ownifie,

    Do you have a sample of the worksheet I can work with?

  12. #12
    Registered User
    Join Date
    10-27-2014
    Location
    London, England
    MS-Off Ver
    2003
    Posts
    8

    Re: Getting Youtube Video View Count

    Yes here is what I am working with. https://www.dropbox.com/s/0j6ril2a1t...test.xlsx?dl=0

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Getting Youtube Video View Count

    Hello ownifier,

    The attached workbook contains the macro shown below. I added a button to the "Videos" sheet to run the macro. If you need to interrupt the macro use CTRL+Break.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    10-27-2014
    Location
    London, England
    MS-Off Ver
    2003
    Posts
    8

    Re: Getting Youtube Video View Count

    Thank you so much for your help!

    I received an error when I clicked "update" http://prntscr.com/7pk4g8

  15. #15
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Getting Youtube Video View Count

    Hello ownifier,

    Sorry to be the bearer of bad news. Apple's version of Office does not support MSXML automation. This can only be run on a PC version of Office.

  16. #16
    Registered User
    Join Date
    10-27-2014
    Location
    London, England
    MS-Off Ver
    2003
    Posts
    8

    Re: Getting Youtube Video View Count

    Thanks Leith Ross!! It almost did the whole document. Here is the completed document, I borrowed my mom's PC! Here is as far as it got: https://www.dropbox.com/s/i4ieft4h9j...%202.xlsm?dl=0

    It missed one and missed the last bits.

    If I add more videos to this excel, how do I make sure it keeps on working?

    Is there a way to click choose starting cell (for the next month and the next month)?
    Last edited by ownifier; 07-07-2015 at 12:08 AM. Reason: another question

  17. #17
    Registered User
    Join Date
    01-07-2014
    Location
    France
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Getting Youtube Video View Count

    Hi There,

    Pretty useful macro;

    However it stops at some point (memory issue?) and the values returned are including HTML, by example "91 186"
    Would be a good improvement to upgrade the macro and remove any HTML code that may have be included in the value.

    Thanks !

  18. #18
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Getting Youtube Video View Count

    Hello Thomas92,

    I have added another macro which will correctly extract the text from any HTML element. This was written after the View Count macro.

    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    10-27-2014
    Location
    London, England
    MS-Off Ver
    2003
    Posts
    8

    Re: Getting Youtube Video View Count

    Thank you guys again! Thanks Leith Ross for writing another macro! I added it (on a PC) to another module and it didn't change the result. Here is what I did. I need a little advice on where to put the macro please.

    https://www.dropbox.com/s/i4ieft4h9j...%202.xlsm?dl=0

  20. #20
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Getting Youtube Video View Count

    Hello ownifier,

    Here is the updated workbook. I ran it once so you can see the results.
    Attached Files Attached Files

  21. #21
    Registered User
    Join Date
    10-27-2014
    Location
    London, England
    MS-Off Ver
    2003
    Posts
    8

    Re: Getting Youtube Video View Count

    Thanks again!! Your super helpful!

    The version you sent me doesn't have N122-N129 filled out even when I run it. And when I re run it N12 has an ERROR0 - Unknown, and makes the spot empty. Do I need to install any plugins to make this work?

  22. #22
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Getting Youtube Video View Count

    Quite an elaborate function to get viewcounts by the way.
    I haven't read the whole thread, but wouldn't this work too:

    Please Login or Register  to view this content.
    Works for me on =Viewcount(A1) where A1 contains https://www.youtube.com/watch?v=owUavO_aovM
    Set reference to Microsoft HTML Object Library

  23. #23
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Getting Youtube Video View Count

    Hello ownifier,

    Okay, I corrected that mistake. I had the macro stopping at the last Total line. It now goes down to the last entry in column "A".

    Please Login or Register  to view this content.
    Attached Files Attached Files

  24. #24
    Registered User
    Join Date
    01-07-2014
    Location
    France
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Getting Youtube Video View Count

    Thanks a lot Leith!

    you were very quick on this one ;-)
    Will test it tomorrow at work as it doesn't run on my mac.

    Thanks again for helping, will be very time saving!

    best,

  25. #25
    Registered User
    Join Date
    01-07-2014
    Location
    France
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Getting Youtube Video View Count

    @JasperD, I gave it a try but doesn't work on my side.
    Error here :
    Please Login or Register  to view this content.
    At least on my mac, will give it a shot on my pc tomorrow.

    thanks!

  26. #26
    Registered User
    Join Date
    10-27-2014
    Location
    London, England
    MS-Off Ver
    2003
    Posts
    8

    Re: Getting Youtube Video View Count

    Read previous comment from Leith Ross about Mac error on page 1.

  27. #27
    Registered User
    Join Date
    10-27-2014
    Location
    London, England
    MS-Off Ver
    2003
    Posts
    8

    Re: Getting Youtube Video View Count

    Thanks again Leith Ross!!! I think that fix will help as we add more videos.

    One thing I noticed is to get rid of the ERROR0 messages is to keep a consistent URL. The macro only works with example URL: https://www.youtube.com/watch?v=7RWEllqh5J0

    It didn't work for N12 because the URL was: http://youtu.be/7RWEllqh5J0

    It didn't work with N122-129 because the URL was http:// not the correct https://

    Love it!!

    I added 2 more videos to test it and it works wonderfully.

    Here is the final document with all of the fixes: https://www.dropbox.com/s/h29f3umzat...inal.xlsm?dl=0

  28. #28
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Getting Youtube Video View Count

    Hello ownifier,

    You're welcome.

  29. #29
    Registered User
    Join Date
    01-07-2014
    Location
    France
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Getting Youtube Video View Count

    Quote Originally Posted by ownifier View Post
    Read previous comment from Leith Ross about Mac error on page 1.
    I did, this is why I said I will try it on my PC ;-)

  30. #30
    Registered User
    Join Date
    05-07-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    2

    Re: Getting Youtube Video View Count

    In Jasper's code, it seems to have trouble with the undefined HTMLDocument class. How do I enable that?

  31. #31
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Getting Youtube Video View Count

    as said in my post:
    Set reference to Microsoft HTML Object Library

    In VBA area, go to tools -> references and select Microsoft HTML object library

    If early binding causes the trouble, then replace:
    Please Login or Register  to view this content.
    With
    Please Login or Register  to view this content.
    But this doesn't take away the need for the reference.

  32. #32
    Registered User
    Join Date
    05-07-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    2

    Re: Getting Youtube Video View Count

    Thanks, works great on PC now. Does this shorter code work on Mac too? I tried adding that reference but it's not there for OSX. Any way to install or other code that might accomplish the same thing across platforms? Thx

  33. #33
    Registered User
    Join Date
    03-03-2014
    Location
    BLUEWORLD
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Getting Youtube Video View Count

    how can i do it getting comments number?

+ 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. trying to add list of worksheets to actual worksheets just like this youtube video
    By dbzisme in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-07-2013, 05:33 AM
  2. Embed YouTube video into an Excel spreadsheet
    By excelblogger in forum Tips and Tutorials
    Replies: 14
    Last Post: 09-06-2012, 03:41 PM
  3. Hyperlink to an exact time in a Youtube video
    By Xx7 in forum Excel General
    Replies: 2
    Last Post: 10-02-2011, 03:31 PM
  4. Great resources youtube video's
    By rwgrietveld in forum Tips and Tutorials
    Replies: 1
    Last Post: 01-10-2010, 10:29 AM

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