VB6 Array Writing to Excel Range

Qpido

New Member
Joined
Oct 9, 2007
Messages
30
Dear Members,

I have a problem with the following code.

Code:
Dim i As Integer
Dim startValue As Long
Dim lMyArray(1 To 103) As Long
startValue = 35
For i = 1 To 103
lMyArray(i) = startValue + (i * 5)
oXLSheet.Range("D6:D109").Value = lMyArray(i)
Next i

The problem is that I only get the same numbers in the cells D6 through D109.

You pros go any ideas?

Thanks,

Jerome
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Perhaps !!
Code:
[COLOR="Navy"]Sub[/COLOR] MG20Apr45
[COLOR="Navy"]Dim[/COLOR] i [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] startValue [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] lMyArray(1 To 103) [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] oXLsheet [COLOR="Navy"]As[/COLOR] Worksheet
[COLOR="Navy"]Set[/COLOR] oXLsheet = ActiveSheet
startValue = 35
    [COLOR="Navy"]For[/COLOR] i = 1 To 103
        lMyArray(i) = startValue + (i * 5)
    [COLOR="Navy"]Next[/COLOR] i
oXLsheet.Range("D6:D108") = Application.Transpose(lMyArray)
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

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