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, out of office, loom, confluence, async collaboration, meeting recaps, remote teamwork, team alignment, knowledge sharing, AI-powered notes, productivity tools, workforce continuity, teamwork collection

Put your meeting notes on autopilot with Loom + Confluence

AI-powered meeting notes keep work moving even if you’re out of the office. Enjoy your well-deserved time off and return refreshed, confident you’ll catch up in no time.

Learn more
AUG Leaders

Atlassian Community Events