Redim Array while using function to fill it

Spurious

Active Member
Joined
Dec 14, 2010
Messages
439
Hello,

I got the following code:

Code:
jData() = ReadISINs(HTMLDoc.body.innerHTML)

The array in my function ReadISINs is filled, but now I cant get jData filled because I need to redim it first.
Given that I dont know how big it should be, how can I tell him to be the same size as ReadISINs array?

Thanks in advance!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try:

Code:
ReDim jData(LBound(ReadISINs) To UBound(ReadISINs))
 
Upvote 0
How have you initially declared jData?

You might not need to redim it if you didn't set it's dimensions when you declared it.

This simple test worked for me:
Code:
Option Explicit
 
Function ReadISINS()
    ReadISINS = Array(1, 2, 3, 4, 5)
    
End Function
 
Sub Test()
Dim jData()
 
    jData() = ReadISINS
    
End Sub
 
Upvote 0
How would that work?
Where should I put it?

Put it right above the line in your original post:

Code:
ReDim jData(LBound(ReadISINs) To UBound(ReadISINs))
jData = ReadISINs(HTMLDoc.body.innerHTML)
 
Upvote 0
spurious

Not sure who your answer was for but have you checked how jData is declared - it might make a difference.
 
Upvote 0
spurious

Not sure who your answer was for but have you checked how jData is declared - it might make a difference.

Yeah, I declared it wrong.

Got another problem:

How do I make this work?

Code:
    jData() = ReadISINs(HTMLDoc.body.innerHTML)
    If Not IsError(UBound(jData)) Then
        Debug.Print jCount, UBound(jData)
        Call WriteISINData(jData(), jS)
    Else
        Debug.Print jCount, "ERROR"
    End If

After a while my arrays are empty and I want to stop the script then.
 
Upvote 0

Forum statistics

Threads
1,224,509
Messages
6,179,192
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top