![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 31
|
The code below will display 10 random numbers in 1 excel row(A1 to J1). How would I make the random numbers display down 1 column (A1 to A10) instead of across a row. Thanks for your help, Jeff. If you replace J1 with A10 it will only display the first random number in each cell.
--------------------------------------- Private Sub Command1_Click() Dim o As Object Dim i As Integer Dim iNumbers(1 To 10) As Integer For i = LBound(iNumbers) To UBound(iNumbers) iNumbers(i) = Int(Rnd * 100) + 1 Next i Set o = CreateObject("excel.application") o.Visible = True o.Workbooks.Add o.sheets("sheet1").Range("A1:J1").Value = iNumbers End Sub [ This Message was edited by: redback on 2002-05-22 10:31 ] |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
Quote:
You need to change A1:J1 to A1:A10 and also specify that the array will be 10x1 i.e. Sub Command1_Click() Dim o As Object Dim i As Integer Dim iNumbers(1 To 10, 1 To 1) As Integer For i = LBound(iNumbers) To UBound(iNumbers) iNumbers(i, 1) = Int(Rnd * 100) + 1 Next i Set o = CreateObject("excel.application") o.Visible = True o.Workbooks.Add o.Sheets("sheet1").Range("A1:A10").Value = iNumbers End Sub Let me know if this works. Dan |
|
|
|
|
|
|
#3 |
|
New Member
Join Date: May 2002
Posts: 31
|
Thanks Dan!
I have been working on this problem all day. I owe ya a beer. Jeff |
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|