rfernandes
New Member
- Joined
- Sep 30, 2013
- Messages
- 1
I've recorded a macro to create columns in the table I want to use, now I want to input things in each row. I found this piece of code that will ask for number of rows of input and display that many blank rows:
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;">Dim j As Long, r As Range
j = InputBox("type the number of rows to be insered")
Set r = Range("A2")
Do
Range(r.Offset(1, 0), r.Offset(j, 0)).EntireRow.Insert
Set r = Cells(r.Row + j + 1, 1)
MsgBox r.Address
If r.Offset(1, 0) = "" Then Exit Do
Loop
</code>
I was wondering how exactly(where in the loop?) do i insert things into these rows based on the columns I have ? Which function lets me that? ... Like I have a columns id, firstname, lastname, date of birth. So like for column first name, I want like a random name chosen from an array of names ? ... date of birth (random dates in a range of dates), a random non-repeatable number for id. exactly how do I associate it to each column ?
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;">Dim j As Long, r As Range
j = InputBox("type the number of rows to be insered")
Set r = Range("A2")
Do
Range(r.Offset(1, 0), r.Offset(j, 0)).EntireRow.Insert
Set r = Cells(r.Row + j + 1, 1)
MsgBox r.Address
If r.Offset(1, 0) = "" Then Exit Do
Loop
</code>
I was wondering how exactly(where in the loop?) do i insert things into these rows based on the columns I have ? Which function lets me that? ... Like I have a columns id, firstname, lastname, date of birth. So like for column first name, I want like a random name chosen from an array of names ? ... date of birth (random dates in a range of dates), a random non-repeatable number for id. exactly how do I associate it to each column ?