View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Vergel Adriano[_2_] Vergel Adriano[_2_] is offline
external usenet poster
 
Posts: 12
Default Array copying to a filtered region

Doug,

Jason did say that arr is a 10x1 array of integers :-) .

I did miss the problem with fitlers.. Taking your approach, but using a 10x1
array:

Option Base 1
Public Sub test()
Dim arr(10, 1) As Integer
Dim i As Integer

For i = 1 To 10
arr(i, 1) = i
Next i

For i = 1 To 10
Cells(i, 1) = arr(i, 1)
Next i

End Sub




"Doug Glancy" wrote in message
...
Vergel,

That would work if he was pasting into a row, but pasting it into a column
will just paste the first value of the array into each cell in the range.
Typically, when pasting an array into a column you need to say:

Range("A1:A10") = WorksheetFunction.Transpose(arr)

to accomplish what your implying, but in Jason's case there is also the
problem of the filter, which also results in just the first element of the
array being pasted into each row. The below works for me, although I
think there may be a better way:

Sub test()
Dim arr(1 To 10) As Long
Dim i As Long
For i = 1 To 10
arr(i) = i
Next i
For i = 1 To 10
Cells(i, 1) = i
Next i
End Sub

hth,

Doug

"Vergel Adriano" wrote in message
...
Jason,

Try this

Range("A1:A10") = arr


"Jason Yang" wrote in message
...
I have a serious problem in writing an array into a range.
The following code works perfectly when I do not use any Filter.

' arr is an 10x1 array of integers
' Need to write this array in the rows 1~10 in the first column
Range(Cells(1,1),Cells(10,1))=arr

But, if the AutoFilter is activated and some rows are hidden, the data
are
written wrongly.

Any clue?




----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption
=----








----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----