Given an example below.. would need to store results in a "array" .. Line 4 says "type mismatch"
Thanks.![]()
Sub arraytest() Dim myarray As Variant For i = 1 To 10 myarray(i) = i Next For i = 1 To 10 Range("B" & i).Value = myarray(i) Next End Sub
Given an example below.. would need to store results in a "array" .. Line 4 says "type mismatch"
Thanks.![]()
Sub arraytest() Dim myarray As Variant For i = 1 To 10 myarray(i) = i Next For i = 1 To 10 Range("B" & i).Value = myarray(i) Next End Sub
Last edited by vidyuthrajesh; 02-29-2012 at 04:19 PM. Reason: Yes.. it works !! Thanks
try this way
or without second loop![]()
Sub arraytest() Dim i As Long Dim myarray As Variant ReDim myarray(1 To 10) For i = 1 To 10 myarray(i) = i Next For i = 1 To 10 Range("B" & i).Value = myarray(i) Next End Sub
![]()
Sub arraytest() Dim i As Long Dim myarray As Variant ReDim myarray(1 To 10) For i = 1 To 10 myarray(i) = i Next Range("B1").Resize(10).Value = Application.Transpose(myarray) End Sub
Last edited by tom1977; 02-29-2012 at 04:02 PM.
Regards
tom1977
If You are satisfied with my solution click the small star icon on the left to say thanks.
![]()
Sub arraytest() Dim myarray(1 To 10) As Variant For i = 1 To 10 myarray(i) = i Next For i = 1 To 10 Range("B" & i).Value = myarray(i) Next End Sub
Regards,
Khaled Elshaer
www.BIMcentre.com
Remember To Do the Following....
- Thank those who have helped you by clicking the Star below their post.
- Mark your post SOLVED if it has been answered satisfactorily:
- Select Thread Tools (on top of your 1st post)
- Select Mark this thread as Solved
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks