Hi everyone I am writing a script in VBA to pull issues from my server and populate it into Excel. Everything is working the only problem being I have to manually enter the number of elements in the for-loop that there are (in this case there are three issues/ids on the website so "3" is the number in the for-loop). If I switch 3 for 10 in the for-loop for example it throws me a "Run-time error '9' Subscript out of range" error. Does anyone know how I can make the range automatically match the number of issues/id in the webpage without me having to manually type the number each time? I am using this JSON parser: https://github.com/VBA-tools/VBA-JSON
Hi @Marcus_Dyer ,
I use Json("issues").Count. Here is an example:
Set Json = JsonConverter.ParseJson(.responseText)
For index_issues = 1 To Json("issues").Count
'do something
Next index_issues
asd
BTW calculations shouldn't be used in loop ranges because they are calculated with every iteration. It should be assigned to a variable (which obviously I don't use ;))
Best,
Michael
Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!
Start here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.