Writing out an array

Orongo

Board Regular
Joined
Nov 6, 2011
Messages
83
Hi,

I am reading in the data into an array and want to write it out, but for some reason it don't write out anything. Just to write out one element works, so the array is not empy.

----------------------

Sub Write_data()
Dim GroupNo, NoRows, ii As Integer
Dim YStart() As Date

NoRows = 1
While Len(Range("Grupp").Offset(NoRows, 0).Value) > 0
NoRows = NoRows + 1
Wend

ReDim YStart(NoRows - 1, 1) As Date

ii = 1
For ii = 1 To NoRows - 1
YStart(ii, 1) = Range("PBD_start").Offset(ii, 1).Value
Next

Range("J20").Value = YStart(12, 1)

End Sub
-----------------------------

Please heeeeellllpppppp
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
I am sorry, the correct version is

----------------------

Sub Write_data()
Dim GroupNo, NoRows, ii As Integer
Dim YStart() As Date

NoRows = 1
While Len(Range("Grupp").Offset(NoRows, 0).Value) > 0
NoRows = NoRows + 1
Wend

ReDim YStart(NoRows - 1, 1) As Date

ii = 1
For ii = 1 To NoRows - 1
YStart(ii, 1) = Range("PBD_start").Offset(ii, 1).Value
Next

Range("J20").Value = YStart

End Sub
-----------------------------

I want the array to start at cell J20 and write out the whole array
 
Upvote 0
I am sorry, the correct version is

----------------------

Sub Write_data()
Dim GroupNo, NoRows, ii As Integer
Dim YStart() As Date

NoRows = 1
While Len(Range("Grupp").Offset(NoRows, 0).Value) > 0
NoRows = NoRows + 1
Wend

ReDim YStart(NoRows - 1, 1) As Date

ii = 1
For ii = 1 To NoRows - 1
YStart(ii, 1) = Range("PBD_start").Offset(ii, 1).Value
Next

Range("J20").Value = YStart

End Sub
-----------------------------

I want the array to start at cell J20 and write out the whole array
Try resizing the receiving range in the highlighted code line to the size of the array...

Code:
Range("J20").Resize(NoRows - 1, 1) = YStart
 
Upvote 0
Yes, but what do the names refer to? Choose Insert|Name|Define and post what's in the Refers to box for both names.
 
Upvote 0

Forum statistics

Threads
1,203,460
Messages
6,055,556
Members
444,796
Latest member
18ecooley

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