Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

For loop script error VBA

Marcus_Dyer July 6, 2020 edited

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 

1 answer

0 votes
Michael Raj July 30, 2020

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

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events