Excel Google Maps Distance and Travel Time Calculator with Directions API

Поделиться
HTML-код
  • Опубликовано: 29 авг 2024

Комментарии • 230

  • @Androo53095
    @Androo53095 4 месяца назад +1

    This tutorial was very helpful. I had a 1000+ addresses I had to evaluate for a school project, and as much of a learning curve as this was, it was still infinitely easier than trying to do it manually. As others have suggested, changing Dim Seconds and Dim meters from "Integer" to "Long" solved the problem of longer distances not calculating. Thank you so much for the guide!

  • @matthewwallace6922
    @matthewwallace6922 3 года назад +7

    This works like a charm. I wanted to suggest changing "Integer" to "Long" as returning meters and seconds may end up exceeding the character limit for Integer. Alternatively you can write a conversion in the VBA.
    Additionally, this seems to now violate Google's ToS for API as it is considered data scraping.

    • @syntaxbyte
      @syntaxbyte  3 года назад

      Interesting point about the ToS. I certainly wasn't intentionally showing something that would violate the ToS, although I don't believe the usage shown in the video does. Google defines scraping as "Customer will not export, extract, or otherwise scrape Google Maps Content for use outside the Services. For example, Customer will not: (i) pre-fetch, index, store, reshare, or rehost Google Maps Content outside the services; (ii) bulk download Google Maps tiles, Street View images, geocodes, directions, distance matrix results, roads information, places information, elevation values, and time zone details; (iii) copy and save business names, addresses, or user reviews; or (iv) use Google Maps Content with text-to-speech services." Probably the closest thing users would use this for is bulk downloading, but I'm not sure at which point you reach "bulk downloading". If you're doing 10 addresses, probably not. If you're doing 1000 addresses, well that may be a different story. Either way, I'm pretty sure all Google's going to do is shut off your API access.

    • @Xynodras
      @Xynodras Год назад

      Thanks for the tip, I had issues with the distance and Long did the trick!

    • @Androo53095
      @Androo53095 4 месяца назад

      Long solved my problem. If anyone else has long distances fail to calculate, this is the solution

  • @miked1686
    @miked1686 3 года назад +7

    2 important points: 1 the difference you are getting in the applications verses the website appear to be driven by time of day. Try on web saying you are leaving at 3AM. 2 - I was doing a larger distance, and kept having an error. The Dim for meters needs to be long as my result was more than 64K.
    Oh and thank you VERY much this was a fun Sunday learning, I really appreciated it.

    • @FrankDTank16
      @FrankDTank16 11 месяцев назад

      Please pin this, it helped a ton. Was getting an error, and this fixed it.

    • @Androo53095
      @Androo53095 4 месяца назад

      Switching from Integer to Long solved my problems too. Great advice

  • @MojtabaGhanidel
    @MojtabaGhanidel 3 года назад +5

    THIS WAS AWWEEESSSOOOOMMMMEEEEE!! Excellent job! Thank you. I changed the ("duration")("value") to ("duration")("text") and it gives me distance in Miles!

    • @davidbriseno6585
      @davidbriseno6585 6 месяцев назад

      did you do anything else besides cause it from value to text. when I tried it I get a #value error

  • @Wiznaz
    @Wiznaz Год назад +2

    Excellent video on how to do this! Some tips that helped me complete my worksheet were:
    -For TravelDistance showing VALUE, remove "Dim meters As Integer" entirely
    -Replace Integer with Long if you have far distances
    -To convert seconds to an hour/minute format, add to the end of your TRAVELTIME code /86400 and then change the cells from General to Time. For example, this should make a route go from 9000 seconds to "2:30" (2hr, 30min)

    • @FredCyrdotcom
      @FredCyrdotcom Год назад

      I still have an error. I did transform the function in Sub to debug it. The problem appears in this line: "Set parsed = JsonConverter.ParseJson(response)". Any help would be appreciated.

    • @pascalhagen4264
      @pascalhagen4264 Год назад

      @@FredCyrdotcom Did you find a solution for this? :/

  • @AnnaJacksonbanana
    @AnnaJacksonbanana Год назад

    This was sooooo super! I was able to create a sheet that tells me how much drive time I need to allot in order to get to my next facepainting gig on time! YOU ARE AWESOME!!! thank you

  • @kats7945
    @kats7945 4 месяца назад +1

    This was SO helpful! How would you modify the code to display only the shortest travel distance? I also need to figure out a way to display the associated map for each record. Appreciate the guidance.

  • @DroisKargva
    @DroisKargva 3 года назад +3

    OK READ THIS GUYS:
    So he did not showed in the video. If you get #Value error please enable directions api. I am noobie as well but I got it work. So go here and read this topic: stackoverflow.com/questions/32994634/this-api-project-is-not-authorized-to-use-this-api-please-ensure-that-this-api
    Also this page is usful to test if your directions api working. developers.google.com/maps/documentation/directions/get-api-key
    Another thing is syntax error. To get rid of the syntax error simply replace all of the "&" with just an "&" in syntax
    Hopefully it helps!

  • @anditote
    @anditote Год назад +3

    Hi, I am getting a compile error - User-defined type not defined. And the text "parsed as dictionary is getting highlighted. Can you please help?

  • @AliPaul-pb7ci
    @AliPaul-pb7ci Год назад

    Thanks alot mate, really helped me in simplifying one of my analysis containing 22K rows of data, which I had to otherwise do manually

  • @GeoffWieczynski
    @GeoffWieczynski 3 года назад +1

    Thanks a lot. I got it working in an hour. Saving me some real time. Well done.

  • @thefurniturepeople886
    @thefurniturepeople886 3 года назад

    hi there want to say thank you very much for this video. it was tremendously helpful for what i am trying to do. I will also tell you that i know not much about coding and vba etc but i just followed us instructions and got the result i needed. thanks for such a detailed video, thanks for your time, and thanks to the people below for commenting on some of the issues they had, it also helped me fix some issues.

  • @rodrigoruiz2701
    @rodrigoruiz2701 4 года назад +15

    Hi, I did it the exact way as the video, but when I use the formula It gives me a #VALUE! for the time and distance, I also wanted to know if this works for coordinates (I also tried using the same direction as the video but I have the same result)

    • @Mechknight5656
      @Mechknight5656 3 года назад

      I have the same problem. I noticed that when I type in the URL into Chrome it doesn't display the code like it does on his - It shows it all as plain text instead of using the Java formatting.
      Have you managed to get that fixed?

  • @allanjackson777
    @allanjackson777 21 день назад

    Thank you for the video.. though I cringed everytime I had to hear you take a sip and put the lid back on.

  • @ntb3
    @ntb3 Год назад

    The distance problem is because you may have picked one of the few buildings in the world that doesn't have an address(house) number. United States Capitol resolves to "First St SE, Washington, DC 20004" which doesn't have an address number, giving unexpected behavior.
    Seems to work perfecting, with the only thing I have noticed is google maps website always floors the duration value, even if it is 10.9333 it will still display 10, while the api returns 11 mins.

  • @michaelthgersen5147
    @michaelthgersen5147 Год назад +1

    Hi again. I'm not getting the ferry thing to work. Do you have any advice on altering the code to work? I've tried this without any results:
    Dim parsed As Dictionary
    Set parsed = JsonConverter.ParseJson(response)
    Dim ferry As Long
    Dim leg As Dictionary
    For Each leg In parsed("routes")(1)("html_instructions")
    ferry = ferry + leg("maneuver")("text")
    ferry = ferry
    Next Item
    GETFERRY = ferry

  • @alazartebeka3390
    @alazartebeka3390 2 года назад

    You deserve a million subs

  • @mg24ification
    @mg24ification 10 месяцев назад

    Thank you so much for this incredible helpful video!

  • @ernestina5869
    @ernestina5869 4 года назад +1

    Thank you for the explanation! Super clear and useful!

  • @aquiviallc600
    @aquiviallc600 4 года назад +1

    You rock like Buddy Holly, man.

  • @heathercrawford5299
    @heathercrawford5299 3 года назад +1

    Good day, Thank you for your video. I have general computer skills and was able to follow the steps and get it working. I was wondering if there was a way to modify the code so that it pulls the public transportation time and distance instead of driving for a project I am working on?

    • @syntaxbyte
      @syntaxbyte  3 года назад +1

      Should just be a matter of adding &mode=transit onto the URL in the code. You can find some more information here: developers.google.com/maps/documentation/directions/get-directions#TravelModes

  • @bbghazal
    @bbghazal 2 года назад

    This is awesome! Can you advise if I can add the "Depart at" value which includes the time and date? I need to know for example how long will it take me from PointA to PointB if I left PointA on March 15th 2022 at 3pm

  • @katrinamcdaniel1002
    @katrinamcdaniel1002 2 года назад

    Thanks so much for this great video. I'm having a small problem with my API - for some postcodes, it returns the travel Time but not the Distance. Do you know why this would be?
    Apart from this, this was so straightforward and I know nothing about APIs, so I truly appreciate the help!

  • @davidcole7171
    @davidcole7171 4 года назад +1

    thanks for the video and supporting notes where great for total novice. i had a list of 20 addresses and they all return accurate kms and time to home and office. except 1 which returned #value for kms to home only... but ok for time and kms to office.... any tips to resolve? many thanks

    • @CarlosGonzalez-fr6ek
      @CarlosGonzalez-fr6ek 3 года назад +1

      Try this instead of using "MSXML2.XMLHTTP" use "WinHttp.WinHttpRequest.5.1", this works fine for me.

  • @TomBishopDiagonal
    @TomBishopDiagonal Год назад

    I was getting a #VALUE error, because my API key had a "-" in the middle so the function was trying to evaluate this. I put the API in the function with a " " around the outside of it, and it worked.

  • @floriannu231
    @floriannu231 3 года назад +1

    Hi there, what could be the reason that this works with adresses from the USA or Mexico, but it does not work with adresses from any European Country (Germany, UK, France) or for example Brazil?

    • @martonvarga2799
      @martonvarga2799 10 месяцев назад

      Have you ever found an answer to this question? I have the same problem

  • @katlegotheledi9456
    @katlegotheledi9456 3 года назад +1

    Thank you for sharing your knowledge, does this work the same way on Mac OS?
    Edit: Got this exact method to work on my M1 mac by virtualizing windows through Parallels(it has a 14-day trial). If you get the value error then you probably need to enable either the directions or distance API, I just enabled both to be sure.

    • @syntaxbyte
      @syntaxbyte  3 года назад +1

      It should work as long as you follow the instructions to install VBA-JSON correctly on Mac. However, there are other users in the comments that have reported problems and I've never personally run the script on Mac.

  • @cruzinsweetsntreats
    @cruzinsweetsntreats Год назад

    About 3 years later: March 26, 2023.... Could it be that despite the icon order for the methods, the walking distance was listed first in the JSON file? I don't know if you looked down the file to see if there was a "2.4 miles" vs the "1.7 miles" listed in the screen view.

  • @toprelaxingtime1569
    @toprelaxingtime1569 2 года назад

    It is like a magic ... Super usefull & Super thanks !!!

  • @primafitra5610
    @primafitra5610 4 года назад +2

    Hi, i tried your code and get #value when tried the traveldistance and traveltime. I think its because the json format is different now, when i tried to open the link in browser there is no "leg" in there. can you help?

  • @Radical199
    @Radical199 4 года назад +4

    Hi, first of all thanks for this video! I did everything as you showed and basically it worked. However I get really strange behavior with the distance calculation. What happens is the following: if I use a city as an origin, it calculates the distance perfectly for each destination that is less than 30 km away. Whenever i try a destination that is further away than that, the distance calculation gives me a #value error....??!! However the travel times calculation continues to work... Any idea how this is possible ? I dont think it has to do with the format of the cell in excel or something like that ? Please help because I really need this functionality.

    • @syntaxbyte
      @syntaxbyte  4 года назад

      Odd. I'd love to do more testing but I'm not in the same city as the computer I usually use for VBA that has this workbook on it. My suggestion would be to make that request in a browser and take a look at the JSON. Maybe there is some sort of structural change?

    • @stomean
      @stomean 4 года назад +5

      Try removing the Dim meters as Integer line.

    • @Radical199
      @Radical199 4 года назад

      @@stomean Heeeee ! that did the job ! cool ! thanks a lot ! Can you explain why it works as well ?

    • @muhammadghous1827
      @muhammadghous1827 4 года назад

      hi @Radical199 did you use the api key of your own ?

    • @Radical199
      @Radical199 4 года назад

      @@muhammadghous1827 yes I did !

  • @mxelectricity
    @mxelectricity Год назад

    This is great. I live in Mexico and street addresses are bad. Is there a way to do this use latitude and longitude instead?

  • @adityabandal9897
    @adityabandal9897 3 года назад

    Loved the video. Like the distance and time travel calculation, how can i find the postal/zip codes of a particular address using the api key. Because my excel sheet contains 20k Plus string address. I want the zip/postal of these address mentioned in excel sheet.

    • @syntaxbyte
      @syntaxbyte  3 года назад

      Your best bet would probably be to use the geocoding API. That's a pretty common question I'm sure so maybe I'll make a video on it soon. developers.google.com/maps/documentation/geocoding/overview

  • @honklertheconkler155
    @honklertheconkler155 3 года назад

    This still works thanks

  • @jackmasters4379
    @jackmasters4379 8 месяцев назад

    Great info. thank you. Is there a way you can do the same using bing maps API? Can you show the steps or the code?

    • @nickoli2022
      @nickoli2022 7 месяцев назад

      I'm new to this, but I would assume you would just replace the strUrl = with the bing "..."

  • @taivos
    @taivos 3 года назад +4

    Thanks for the video! Interestingly enough, for longer routes (e.g. 200KM), I'm getting #N/A error in Excel (shorter ones are OK). Any idea what's that about? According to the JSON file, Google Maps provides the data, but feels like some parse error. Dim meters as Long didn't help either.

    • @mg24ification
      @mg24ification 10 месяцев назад

      A bit late but maybe it still helps, I had the same problem, you have to change dim meters as Double. Float etc. are not possible in VBA

  • @mohitgupta5593
    @mohitgupta5593 4 года назад +2

    Hi, thanks for this amazing video!
    I have more than 10k orgin/destination pairs. What do I have to incorporate into the code so that I do not cross the limit of "Maximum of 25 origins or 25 destinations per request"?

    • @PaulinaBran
      @PaulinaBran 4 года назад

      Hi, did u calculate the distances? i have the same issue, thanks!

    • @timwilliams347
      @timwilliams347 3 года назад

      @@PaulinaBran each cell is its own request

    • @XEQUTE
      @XEQUTE 2 года назад

      same

  • @lisaha6745
    @lisaha6745 2 года назад

    Hi,
    thank you for this. I really needed it for a data project I am working on. I wanted to ask is there a way to change the travel type, instead of by car, but by public transportation such as the metro?

    • @syntaxbyte
      @syntaxbyte  2 года назад

      Yes, you simply add &mode=transit to the URL. You would need to expand the parsing portion a bit to actually know what mode of public transit it wants to use.

  • @michaelthoegersen
    @michaelthoegersen Год назад

    Hey! Great video. Got it working straight away. I have a follow-up question. Is there an easy way to pull out info about whether or not your route includes a ferry in a separate cell in excel? ☺️

    • @syntaxbyte
      @syntaxbyte  Год назад +1

      You should be able to just pull that information from the same JSON file. Whether this is easy or not might depend a little on your personal programming ability.

    • @michaelthgersen5147
      @michaelthgersen5147 Год назад

      @@syntaxbyte Thanks! I am also wondering about multiple routes. You say that you assume that the first route is correct. How can i get alternatives?

  • @v90cross2
    @v90cross2 4 года назад

    awesome work and description! thanks

  • @luisfalsiroli8178
    @luisfalsiroli8178 2 года назад +1

    Hello this video is AMAZING! But I am having issues running the code. I have done exactly what you have done and I get an error function. The only difference between the steps in your video and what I am actually doing is that when you type "Set Parsed = JsonConverter.ParseJason" when I type "Set Parsed = JasonConverter" and then I place the period the files do not pop up. You get 7 options that pop up and you select the one under "Json Options" called "Parselso" (video minute 10:25) and I do not get anything. Its like VBA is not reading the file that I imported yet I did submit the file and I can see the code. I believe that has to be the source of the issue. PLEASE HELP!!!!!!!!!!!!!!!!!!!

  • @3xnheroes
    @3xnheroes 4 года назад

    Hi there, Your video is really a good one and you describe all the process very clear.
    But after I try to use it on excel, it continuously asking for macro reference. As if the macro doesn't exist.
    can you help me with this error?

  • @themathman893
    @themathman893 2 месяца назад

    i created the api key and am doing the same thing in the video. copied his text and every thing and i get a #name? error for the result. anyone have any idea why?

  • @delwynhobbs3548
    @delwynhobbs3548 3 года назад

    This is amazong thank, how do I put multiple desitnations in etc?

  • @whitneyswinscoe9018
    @whitneyswinscoe9018 2 года назад

    Hiya,
    Thank you this has really helped. I have read some comments and have sorted the LONG issue but now when trying to distances I get a #NAME error when using the distance. I can't figure out what I'm doing wrong :( any advice?

  • @XEQUTE
    @XEQUTE 2 года назад +1

    HI syntax byte, I need to query all shops near me and get thier contact data etc into excel ,
    Can i do this in excel?

    • @syntaxbyte
      @syntaxbyte  2 года назад +1

      You could probably use the Google Places API to get the information you're looking for, though you'll want to be aware of quotas etc. If you don't need to regularly update this info you may just want to use something like Python and save what you query as a CSV to be used for analysis in Excel.

  • @stomean
    @stomean 4 года назад +2

    I keep getting an #Value message in the distance calculation. The time calculation is working perfectly. I have triple checked the code and everything looks correct. PLEASE help me!

    • @stomean
      @stomean 4 года назад +1

      Actually, after reading the comment from Radical199 below, I realized I am having exactly the same issue.

    • @stomean
      @stomean 4 года назад

      I just figured it out...you need to remove the Dim meters as Integer line. Now it's perfect! Thanks for the great vid. You just helped me tremendously.

    • @fastandserious4273
      @fastandserious4273 4 года назад

      @@stomean what does it mean?

    • @muhammadghous1827
      @muhammadghous1827 4 года назад

      Did you use the API key of your own ?

    • @rodrigoruiz2701
      @rodrigoruiz2701 4 года назад

      @@stomean I tried that because I have the same issue, but it doesn't work for me, any API functions I have to enable or something?

  • @jordanheap3272
    @jordanheap3272 3 года назад +1

    Does this work when using excel on mac? I cant seem to locate the required references

    • @toddnelson5083
      @toddnelson5083 Год назад

      same

    • @tur1500
      @tur1500 6 месяцев назад

      Any chance that you might have found them? I am also using mac and can't locate the references.

  • @oskarfahlstedt2096
    @oskarfahlstedt2096 2 года назад +1

    Hi, thank you for a great video. I have one problem (at least) that someone might be able to help me. The problem, in the VBA are the lists in the function using comma (,) to separate each variable. However, in the European standard of Excel are they variable separated by a semicolon (;) which I THINK is the reason why I get the #VALUE problem. I've tried to use the addresses as in the video as well as others. No luck. I have tried to change the setting through the control panel etc but I'm not able to change the list setting in excel from (;) to (,). Any tips?

    • @katrinamcdaniel1002
      @katrinamcdaniel1002 2 года назад +1

      I also have a value problem, I would be interested in knowing the answer.

    • @filippomauro4846
      @filippomauro4846 2 года назад

      did you solve the problem?

    • @moast1996
      @moast1996 2 года назад

      Have the exact same issue...anyone of you able to solve the problem? :)

  • @Rooo8
    @Rooo8 9 месяцев назад

    I successfully used this for years, but now I only get a value response in excel. I suspect the problem lies in the JSON Converter. Could you please try it again and see if you also have this problem? Does anyone else have issues? Last time, I successfully used this, was in May 2023. Now, the same file with the same data will not work anymore.

    • @Rooo8
      @Rooo8 9 месяцев назад

      The issue were some special German characters ü, ö, ä. But I wonder why it only now caused problems. Maybe google changed something here? I just replace these characters with different ones in my excel file before sending them to the server.

  • @chowhaw3267
    @chowhaw3267 Месяц назад

    Pal the video is good… however there is too many water drinking sound behind 😂😂😂😂

  • @shitizarya9505
    @shitizarya9505 2 года назад

    Hi, I tried replicating this exactly but it doesn't work for some of the addresses. Any idea why that might be happening?

  • @Bran554
    @Bran554 3 года назад

    Hows it going boss, this was more than helpful with what I was trying to accomplish. One question for you though if you have the time. It was working perfectly fine yesterday, but now the TRAVELTIME and TRAVELDISTANCE are returning the #NAME? errors. I don't see many solutions for this in the comments, so I hope you could help.

    • @Bran554
      @Bran554 3 года назад +1

      For everyones reference with this issue, I figured it out, make sure you have macros enabled in the trust center under File and Options.

    • @rachelkelly512
      @rachelkelly512 3 месяца назад

      @@Bran554 Bless you! This was driving me nuts!

  • @diktanariswari1343
    @diktanariswari1343 Год назад

    Hello, does the api request get charged when I press enter continuously, how about creating a button to run when all addresses are done being entered, I think it will be costless

    • @syntaxbyte
      @syntaxbyte  Год назад

      It will send off a new request each time the formula is evaluated, yes. You may wish to just change your calculation options.

  • @stinershomeandlandscape
    @stinershomeandlandscape 10 месяцев назад

    I'm thinking that it may be giving you distance "as the crow flies" just straight over

  • @danielkatievanoverbeke1637
    @danielkatievanoverbeke1637 4 года назад

    Thank you for this great info. I experience however a "Compile Error" "Syntax Error" which then highlights the first function line. Please let me know if there is a quick fix. Thanks

    • @syntaxbyte
      @syntaxbyte  4 года назад

      Can you share your code as a github gist?

    • @danielkatievanoverbeke1637
      @danielkatievanoverbeke1637 4 года назад

      @@syntaxbyte Syntax Error #165
      Above is the submitted error code

    • @syntaxbyte
      @syntaxbyte  4 года назад

      That's the error code, yes, it just means it couldn't interpret something as valid VBA. Without seeing your code, I can't tell you what you may have incorrectly typed in. I would recommend just copy-pasting from my website if you haven't already.

    • @Jrandomefilmstuffoe
      @Jrandomefilmstuffoe 4 года назад

      I had the same error, I replaced all of the "&" with just an "&" and that worked for me

    • @bolajitojola674
      @bolajitojola674 3 года назад

      @@Jrandomefilmstuffoe this works for time though but still got error with distance

  • @semhoz640
    @semhoz640 2 года назад

    Hi, Thanks for this tutorial! However I want to calculate the shortest distance between two places, how can I change this? Now it always takes the first option, but this is not always the shortest one 😅

    • @syntaxbyte
      @syntaxbyte  2 года назад

      You would need to modify the code to look through all solutions and then take the shortest one.

  • @joaquinignaciomolina
    @joaquinignaciomolina 2 года назад

    I am very new with all this. How can I open the JSON interface as seen in the video? Thanks!!!

    • @syntaxbyte
      @syntaxbyte  2 года назад +1

      I assume you are talking about the interface that was shown in Firefox. That comes with Firefox by default, and will appear when opening a JSON file with it. If you use a different browser, you could try Firefox for this use case or just install an extension.

    • @joaquinignaciomolina
      @joaquinignaciomolina 2 года назад

      ​@@syntaxbyte Thank you so much! Yes, that was what I was asking for! Again... I am really new on this! Lol.... and trying to get a txt file with only Directions format as shown on GoogleMaps and maybe to get some .jpg file with the Location point, and I think this is good chance to start with (?) Thanks again for answer!

  • @ekafaa
    @ekafaa 4 года назад

    Hello, thank's for the video, it is so interesting, you explained it in detail both through this video and the written version. I did in my excel ( I am using excel 2016), but it can't work, I do exactly the same as your code, and then I also copy your written code and running it in my excel, but I got #name? as a result. Can you help me figure this out? What did I do wrong? Thank You

    • @syntaxbyte
      @syntaxbyte  4 года назад

      Seems like Excel doesn't recognize the function. Make sure you are using Function not Sub, and make sure it's in an area the workbook can access.

    • @ekafaa
      @ekafaa 4 года назад

      @@syntaxbyte Thanks a lot for your help, it is work now, I forget to enable the Direction API when I copy the credential/key API.

  • @bradthatcher5816
    @bradthatcher5816 3 года назад

    Hi there, thank you so much I found this very useful. Does anyone know what syntax I should use to create a flag if a Toll Road is used? I can see that "\u003eToll road\u003c/div\u003e" is returned in a "html_instructions" when a roll road is used. Or if it the code module could add 1 each time it finds the Toll Road used for directions? e.g if in 3 HTML_instructions '3' would be returned. meaning from point A-B 3 toll roads are used. Perhaps using the instr function?

    • @raseclc
      @raseclc Год назад

      Hey,
      Have you found an answer to this yet?
      I'm trying that too, I saw that the Google Directions API has instructions for Tollinfo but I still can't get the function right in the VBA module

  • @user-qm4ir6zr2n
    @user-qm4ir6zr2n 4 года назад

    Thank you for the great tutorial. I have a similar question as Mohit below. I have multiple list of pairs I want to calculate the distance, but it seems like I get a #VALUE! error after the first row. How can I fix this problem? Thanks again for the amazing vid.

    • @mohitgupta5593
      @mohitgupta5593 4 года назад

      Hi, please do let me know in case you figure it out :)

    • @CarlosGonzalez-fr6ek
      @CarlosGonzalez-fr6ek 3 года назад +1

      @@mohitgupta5593 I don't know if this answer will help you, but I changed the object type. When I debugged the code I used to have an incomplete json responseText. Check if this is your case with the Local Window and copy your answer string value. In case you have an incomplete value of the json result change the object, instead of using "MSXML2.XMLHTTP" use "WinHttp.WinHttpRequest.5.1", this works fine for me.

    • @timwilliams347
      @timwilliams347 3 года назад +1

      @@CarlosGonzalez-fr6ek Yes! This fixed my issue!!!

  • @Oliver_H1995
    @Oliver_H1995 Год назад

    Anyone who have tried to incorporate a specific departure time to the macro/formula?

    • @syntaxbyte
      @syntaxbyte  Год назад

      You simply need to add departure_time to the URL. You can see optional parameters here: developers.google.com/maps/documentation/directions/get-directions#required-parameters

  • @kll715
    @kll715 4 месяца назад

    Hi everyone, I am new to this but I keep getting compile error syntax error anybody know how to fix this?

    • @syntaxbyte
      @syntaxbyte  4 месяца назад

      A syntax error means something you typed is not valid code. Without more information, there's no more help myself or anyone else can provide.

  • @thomasschibelius7391
    @thomasschibelius7391 2 года назад

    any advise when the error Request_denied shows up? what can be the issue and how to solve it?

  • @robertosuarez1675
    @robertosuarez1675 3 года назад

    Great video and presentation! I did it exactly but I got a 424 error in the "Set parsed = jsonconvert.ParseJSON(response)" line. I am trying to figure out What I am missing? Could you help me? Maybe is the JsonConverter module code. Any other clue?

    • @CrapAtBest
      @CrapAtBest 5 месяцев назад

      Hope you figured it out within the last 2 years, but just in case...it should be "Set parsed = JsonConverter.ParseJson(response). - you missed the 'er' after convert. I just did the exact same thing and happened to see your comment. Easy to miss.

  • @mohamedkassim-uz8px
    @mohamedkassim-uz8px Год назад

    I keep getting a compile error. travel time =0 all the time

  • @shreyansmishra2910
    @shreyansmishra2910 3 года назад

    What is limit to find in one day ?

  • @jan80808
    @jan80808 3 года назад

    @syntaxbyte Hi I keep getting an value error and the function line is highlighted in yellow, please can you help me on this been trying to figure it out but with no luck.

    • @whitneyswinscoe9018
      @whitneyswinscoe9018 2 года назад

      I was getting this, It's because I failed to add the Scripting and Win things

  • @wzr69
    @wzr69 3 года назад

    I've got problem with this code, Duration is working well but Distance is giving me #ARG! problem. Can you help me with this?

  • @shoaibkhan9146
    @shoaibkhan9146 3 года назад

    Hi, great tutorial and I learned a lot! I am trying to go to one level deeper, for example, to get the walk from a location to a transit. I have adjusted the url already for mode transit, however i m having trouble understanding and editing this part:
    For Each leg In parsed("routes")(1)("legs")
    seconds = seconds + leg("duration")("value")
    Next leg
    Going back to google api json file, I wish to get the duration value of routes>legs>steps (i.e. one level deeper). Usually, that step is the walking from origin to nearest transit, which is exactly what I am looking for. How exactly can I edit the above code to return the first step duration value? Also, it would help a bit if you could elaborate on how this line works: "For Each leg In parsed("routes")(1)("legs")
    ", how does VBA read this code as?
    Thanks a lot for your time and help!

    • @syntaxbyte
      @syntaxbyte  3 года назад +2

      Thanks for the question. That line begins a For Loop, which means the code in between For Each and Next will be run for every leg of the trip. You could do the same thing inside to loop the steps (nested for each loop). If you simply want to get the seconds for the first step, you could do seconds = seconds + leg("steps")(1)("duration")("value").

    • @shoaibkhan9146
      @shoaibkhan9146 3 года назад

      @@syntaxbyte Great, that was perfect. Thanks a lot for your explanation. I only started learning VBA a few days back in an attempt to do what you did in the video. Strangely, I was sort of close to the answer you gave. What I had written in my code was seconds + leg("steps")("duration")("value"). Obviously that gave me a #value error but I could not understand why it did give an error, and why adding a (1) to the equation solves it. Maybe to simplify my question, I'm trying to understand what (1) means? Thanks for your help!!

    • @syntaxbyte
      @syntaxbyte  3 года назад +2

      Since steps is an array (a list of multiple values of the same type), you need to specify an index which is what the (1) does. Most languages start at 0 but VBA sometimes starts at 1, as is the case here. So (1) gets the first step in the steps array. Arrays are symbolized in the JSON response by the square brackets [].

  • @gregerfulgerman7802
    @gregerfulgerman7802 3 года назад

    Thanks for the tutorial (and code!). I followed the instructions but im returning a couple specific errors. Traveldistance returns a #value no matter what i put in. And traveltime works but only up to a certain distance (I can go from tallahassee to atlanta fine, but not from tallahassee to houston). Any ideas? =TRAVELTIME(A16, A17, B14) Thats the formula im using (replace time with distance for the other) with A16 and A17 being tallahassee and houston

    • @syntaxbyte
      @syntaxbyte  3 года назад

      Hey Greg, try replacing Int with Long or Variant to fix the issue with TRAVELTIME. To be honest, I'm not sure what could be wrong with your traveldistance. To debug these things I usually log the JSON response and step through my code to see where things might not be lining up.

    • @garrettvandergriff704
      @garrettvandergriff704 3 года назад

      @@syntaxbyte I had been using this over the past few months with no issues, but recently noticed I am getting a #value issue on traveldistance as well. Is there anyway you could explain further on how to debug using the JSON response? it seems like something is off on my response (apologies, i am no coder)

    • @syntaxbyte
      @syntaxbyte  3 года назад

      Sure. It's a bit tough if you have no coding experience, but usually I start by logging the response to the console or using the MsgBox function to see the actually response. If it comes through pretty dirty just copy it and find a formatter online that can make it a bit more readable. The response is what the Google API is giving you. The rest of the code just interprets that response to pull the right information out of it. You want to kind of walk through your code line by line and make sure that the "JSON path" so to speak that you are using in your code and the response you are actually seeing line up. JSON is made up primarily of objects (key/value pairs) and arrays (lists of values). So where you see parsed("routes")(1)("legs") that means that inside the base object there should be an array called routes, which you are getting the first item of, and that item has a value (array) named legs. You can also try logging values within the foreach loop to see if it's adding them up right or if you're getting some kind of value in the loop that you don't want.

  • @serkankdr7538
    @serkankdr7538 4 года назад

    Hello, I wanted to ask you one thing, is it possible to do that with coordinates? I would like to enter lattitude and longitude instead of exact address. Can you help me about this? Thank you.

    • @syntaxbyte
      @syntaxbyte  4 года назад +2

      Yes. You just enter the coordinates in the cell instead. Should be lat,lon. You don't need to change anything in VBA

    • @serkankdr7538
      @serkankdr7538 4 года назад

      @@syntaxbyte Very nice, but could you please share the template excel file with us? This would be wonderful. Thank you!

    • @syntaxbyte
      @syntaxbyte  4 года назад

      I did try and upload the file on my website but Wordpress seems to block it and I don't really know how to allow it. However, if you go to my written tutorial linked in the description the code is there and you can just copy and paste it into the VBA editor.

  • @ItsMe-ic1gb
    @ItsMe-ic1gb 3 года назад

    is this google maps specific or would this work for other map websites?

    • @syntaxbyte
      @syntaxbyte  3 года назад +1

      If you understand the code and the other map site has a JSON API you could use the same technique, because it works with virtually any JSON API. I think there was another commenter that had it up and running using the Bing API.

  • @DavidWilliams-wj4sc
    @DavidWilliams-wj4sc 2 месяца назад

    too much drinking, geez. when i do trainings at work i don't sniffle or drink 1000x. And it was giving you 1.7 miles as straight line distance which is totally useless unless you're flying a plane.

  • @cetinsyk
    @cetinsyk 4 года назад

    hello, I do exactly the same as the video, but the result is an error in excel. what is missing. I have excel 2013. thanks.

  • @nicolasguerrero8283
    @nicolasguerrero8283 Год назад

    hi, how could i do this with coordinates?

  • @santiagogonzalezmonsalve3858
    @santiagogonzalezmonsalve3858 Год назад +1

    Worked perfect 🫶🏻

  • @chrisward7550
    @chrisward7550 3 года назад

    How do you use this for Mac Excel? I added in the VBA-Dictionary, but receive a #VALUE! in my cell. I am able to get distance and time copy and pasting my http address with my apikey, so I think there may be an issue with the http get request through IOS Excel vba.

  • @lanksterprice
    @lanksterprice 3 года назад

    The google api wants a credit card.... Dont have one... how do you get a key? Do you really need a key... why cant it just seach?

    • @syntaxbyte
      @syntaxbyte  3 года назад

      Use to be able to but now I don't think you can, you could try the Bing directions API instead as another user mentioned in their comment. Definitely don't need a credit card to sign up for it.

  • @victoriagamez4718
    @victoriagamez4718 2 года назад

    HELP!! I have been working on my excel sheet for months now, It works it one cell only, the others all have a #value error. I have no idea why?

    • @syntaxbyte
      @syntaxbyte  2 года назад

      Pretty difficult to say without more information, but my guess is it's something to do with the input. In regular Excel, this is commonly due to an absolute vs relative cell referencing issue changing inputs you wanted to remain static between runs. I would recommend changing each input one by one to see if one is causing an issue with the code.

    • @victoriagamez4718
      @victoriagamez4718 2 года назад

      @@syntaxbyte I have done that over and over, can't figure out why. Can I share it with you somehow?? I am not a programmer at all, loved your video. BTW!

  • @jeffreymartinez958
    @jeffreymartinez958 Год назад

    DO THIS WORK IN MACBOOK?? IF SO, HOW??

  • @rickphp5400
    @rickphp5400 4 года назад

    It is not working for me. I have tried all the steps that you have mentioned but do not know what I am doing wrong and how can I get this worked. Please help.

    • @syntaxbyte
      @syntaxbyte  4 года назад

      Thanks for the comment! Unless you tell me a bit more (such as an error message you are experiencing) I can't really help.

    • @rickphp5400
      @rickphp5400 4 года назад

      @@syntaxbyte I am getting this error when executing the formula in the worksheet. Error > i.imgur.com/YaEE6tm.jpg. I am sorry but I do not know VB Scripting just followed the instruction.

  • @chandratalerico8944
    @chandratalerico8944 4 года назад +1

    Very helpful and I feel I'm close. I get that I have an error and brings me back to the module to the stringurl line, is there something wrong that I missed in copying and pasting from the blog?
    strUrl = "maps.googleapis.com/maps/api/directions/json?origin=" & origin & "&destination=" & destination & "&key=" & apikey

    • @syntaxbyte
      @syntaxbyte  4 года назад

      Are all of those variables initialized? What does the error say?

    • @lolarenan359
      @lolarenan359 4 года назад +1

      I am encountering the same issue. Did you manage to make it work?

    • @stuarthester2236
      @stuarthester2236 4 года назад

      replace & with &

    • @lauraguerrero4671
      @lauraguerrero4671 4 года назад

      @@lolarenan359 hi lola, by any change you got it right? Im having the same issue

    • @lauraguerrero4671
      @lauraguerrero4671 4 года назад

      @@stuarthester2236 I did try it , but it is not working. any other suggestions?

  • @jorgemaldonado1792
    @jorgemaldonado1792 3 года назад

    error appears !!! not defined by user

  • @Mr.Antiques
    @Mr.Antiques 3 года назад

    Thanks for the vid! I followed the steps all the way until you reached the travel time of 622. I get a #VALUE! It says that a value used in the formula is in the wrong data type. I rechecked the code and I cant see an issue there. I also tried different addresses. I also tried by changing the format of the cells to text instead of General to see if that did the trick. What am I missing?

    • @syntaxbyte
      @syntaxbyte  3 года назад +8

      Hi Bryan, this has been a commonly reported issue with the code presented in this video. The problem is that the time in seconds is often larger than 32767 which is the maximum value from an integer. You can try replacing Integer with Variant or Long and the #VALUE! error should go away. Thanks!

  • @jorgemaldonado1792
    @jorgemaldonado1792 3 года назад

    here you can copy and paste the macro? Please!

    • @syntaxbyte
      @syntaxbyte  3 года назад

      All the code is on my website at syntaxbytetutorials.com, link is in the description.

  • @nganpham4785
    @nganpham4785 3 года назад

    Hi, I copy your code exactly but still get error "#VALUE!" for travel time & travel distance. Anyone can help me? Many thanks

    • @paulmillard188
      @paulmillard188 3 года назад

      I had this code working but it has stopped in the last few weeks. I guess something has changed

    • @Bran554
      @Bran554 3 года назад +2

      Go into your code and change Int to Long where it said "Dim seconds As Int" and "Dim meters as Int"

  • @Mutues
    @Mutues 3 года назад

    How can I add walking mode ?

    • @syntaxbyte
      @syntaxbyte  3 года назад

      You need to pass mode=driving, developers.google.com/maps/documentation/directions/overview#TravelModes

  • @bulldogwebsolutions6165
    @bulldogwebsolutions6165 3 года назад

    Not sure if you know or not but your website has a redirect hack it keeps redirecting me to load05 website

    • @syntaxbyte
      @syntaxbyte  3 года назад

      Hey thanks for the comment. My suspect is a certain ad unit on the site is causing the problem. I have tried that network before and ran into issues, but I thought it was probably with a different one of their units. I have disabled that unit for now. Feel free to give it another try. Only amazon ads now. I appreciate the informative comment.

    • @bulldogwebsolutions6165
      @bulldogwebsolutions6165 3 года назад

      @@syntaxbyte seems to be working now. And thanks for the video as well it works great for me.

  • @juliencouque5459
    @juliencouque5459 Год назад

    Do we have to pay for API key ?

    • @syntaxbyte
      @syntaxbyte  Год назад

      You don’t pay for the key, the fees are based on how much you use and there is a free allowance. I believe you do need to add a credit card so they have a way to charge you if you go over the free limit

  • @flyfastmedia
    @flyfastmedia 3 года назад

    This does not work at all. Followed steps 5 times...

    • @syntaxbyte
      @syntaxbyte  3 года назад

      Thanks for watching the video, trying the steps, and commenting. I am certain given the number of people who have commented below that have experienced success that these steps work. However, many other commenters have also had difficulties or pointed out flaws in the code presented in this tutorial. Could you please share more information about the error you're getting? It's the only way to receive any actual help. Otherwise, you are ranting. Please don't rant.

  • @cristianarguello7887
    @cristianarguello7887 4 года назад

    Does this cost money to run the API? Or is this free?

    • @syntaxbyte
      @syntaxbyte  4 года назад +1

      I've never had to pay for my use. The API isn't free, it costs $0.005 per use but there is a $200/month credit available. So for a small amount of use, it is effectively free. See developers.google.com/maps/documentation/directions/usage-and-billing

    • @lanksterprice
      @lanksterprice 3 года назад

      It will cost you money.. it wants your credit card. Im just not cool with that. Every time you search it eats away at your little credit.. One day it will just bill you for more and more.... Its 1 cent a search now...

    • @DroisKargva
      @DroisKargva 3 года назад

      @@lanksterprice no it says it isnt going to charge you. Its just to verify that you are not a "robot"

  • @4511660
    @4511660 3 года назад

    please help me

  • @PrafullVijay
    @PrafullVijay 2 года назад

    Wish you had explained it in a way so that people who are at beginners level could have also understand it. You were presenting as if you are not explaining it but you are just doing it for the sake of just showing it. It is a good video but I think you could have done better in explaining things as a trainer. Also, your results are not accurate too. As a programmer, I thought you will be good too. But, I guess I will look other video by other programmers.

    • @syntaxbyte
      @syntaxbyte  2 года назад +1

      Thanks for the comment. I can understand that this video may be a little advanced for those who do not have prior exposure to VBA, though I would say that others have commented that it works for them even though they don't have VBA experience or necessarily understand all the code. Unfortunately, to do something like this in a way you truly understand every aspect if you are a beginner would take probably an 8 hour course rather than a 20 minute video. So I have to strike a balance, but thanks for the feedback.

    • @PrafullVijay
      @PrafullVijay 2 года назад

      @@syntaxbyte Can you please atleast tell where did you get the link to use your API where you get the display codes when you calculated the distance from Disney to Universal?

    • @syntaxbyte
      @syntaxbyte  2 года назад

      The link I used between those two places was just from google's documentation: developers.google.com/maps/documentation/directions/quickstart

  • @TheD00mnezeu
    @TheD00mnezeu 3 года назад +1

    what a waste of time, he did not provide any code, just posted a link where he puts a code full of errors that you fix by reading the comments from other users, after that it still doesn't work

  • @kaydenporeches
    @kaydenporeches 11 месяцев назад

    Hi, I am getting a compile error - User-defined type not defined. And the text "parsed as dictionary is getting highlighted. Can you please help?

    • @syntaxbyte
      @syntaxbyte  11 месяцев назад

      Did you install VBA JSON?

    • @kaydenporeches
      @kaydenporeches 11 месяцев назад

      yes I've imported the JsonConverter.bas@@syntaxbyte