Re: how do i set up random numbers in a cell & row? by Helmut
Helmut
Fri Sep 01 14:15:52 CDT 2006
Hi,
Rows are horizontal, columns are vertical.
For a 6 x 6 table, or to be more precise,
for the first 6 rows and the first 6 columns
in a uniform table,
whereby uniform means, all rows got the same number of cells,
all columns got the same number of cells.
Sub Test444()
Dim oTbl As Table ' 1st table in doc
Dim r As Long ' row
Dim c As Long ' column
Randomize
Set oTbl = ActiveDocument.Tables(1)
With oTbl
For r = 1 To 6
For c = 1 To 5
oTbl.Cell(r, c).Range.Text = CLng(55 * Rnd + 1)
Next
c = 6
oTbl.Cell(r, c).Range.Text = CLng(42 * Rnd + 1)
Next
End With
End Sub
HTH
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"