Jared 4

New Member
Hi... I have a random number in a cell... everytime I generate a new random number in that cell, I want it to be recorded in a column...so by the time I have generated six random numbers, the column will be six rows deep.

Can this be done?

Thanks!!!!
Jared

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Von Pookie

MrExcel MVP
How is the random number being generated?

Jared 4

New Member
with a button using a macro that involves the randbetween() formula

Banker1

Active Member
Here is something I came up with. You'll have to adjust the code to work with your existing macro as well as have it dump the random numbers into the column of your choice (I would set the start cell in the beginning of the macro)

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> Test()
<SPAN style="color:#00007F">Dim</SPAN> Start <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Integer</SPAN>

<SPAN style="color:#00007F">If</SPAN> ActiveCell.Row = 1 <SPAN style="color:#00007F">Then</SPAN>
ActiveCell.Offset(1, 0).Select
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>

Start = ActiveCell.Row

<SPAN style="color:#00007F">Do</SPAN> <SPAN style="color:#00007F">Until</SPAN> ActiveCell.Row - Start = 5

ReRun:
<SPAN style="color:#00007F">If</SPAN> ActiveCell.Value = "" <SPAN style="color:#00007F">Then</SPAN>
ActiveCell.Value = ActiveCell.Offset(-1).Value + 1
<SPAN style="color:#00007F">ElseIf</SPAN> <SPAN style="color:#00007F">Not</SPAN> ActiveCell.Value = "" <SPAN style="color:#00007F">Then</SPAN>
ActiveCell.Offset(1, 0).Select
<SPAN style="color:#00007F">GoTo</SPAN> ReRun
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>

<SPAN style="color:#00007F">Loop</SPAN>

<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

I'm sure someone else will come up with a more efficient way to do the same thing... this is to get you started.

Replies
2
Views
277
Replies
41
Views
1K
Replies
5
Views
172
Replies
6
Views
321
Replies
4
Views
85

1,195,906
Messages
6,012,234
Members
441,685
Latest member
12345695959

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back