How to create 700 random numbers in a range in three Excel columns

I need to learn how to populate a new, empty Excel 2010 spreadsheet properly.  I need three columns of 12 digit integers, with each column having 700 such numbers in a range I will specify.   Please start with the basics, because I'm not getting anywhere with all my "trial and error".  TIA
LVL 3
sasllcAsked:
Who is Participating?
 
Martin LissOlder than dirtCommented:
Sub GenerateRandom()
Dim intCol As Integer
Dim intRow As Integer

Randomize

Application.ScreenUpdating = False

For intCol = 1 To 3
    For intRow = 1 To 700
        Cells(intRow, intCol) = WorksheetFunction.RandBetween(100000000000#, 999999999999#)
    Next
Next

Application.ScreenUpdating = True
End Sub

Open in new window

0
 
Martin LissOlder than dirtCommented:
Sub GenerateRandom()
Dim intCol As Integer
Dim intRow As Integer

Randomize

Application.ScreenUpdating = False

For intCol = 1 To 3
    For intRow = 1 To 700
        Cells(intRow, intCol) = WorksheetFunction.RandBetween(1, 200)
    Next
Next

Application.ScreenUpdating = True
End Sub

Open in new window

0
 
Martin LissOlder than dirtCommented:
Oh, sorry, I didn't notice that you need 12-digit numbers. Be back soon.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
sasllcAuthor Commented:
Can I somehow put this code into my excel spreadsheet?  If so, how and where do I do so?  Or will I need to write a vb app to do this?
0
 
Martin LissOlder than dirtCommented:
As a formula you can do

= RANDBETWEEN(100000000000, 999999999999)
0
 
Martin LissOlder than dirtCommented:
will I need to write a vb app to do this?
What i provided in post ID: 42406146 was a Sub that you can execute from within Excel, and here's how.

In Excel, Press Alt+F11 to open the Visual Basic Editor (VBE)

Right-click on your workbook name in the "Project-VBAProject" pane (at the top left corner of the editor window). If you don’t see an existing module then select Insert -> Module from the context menu. Otherwise just select the module.

Copy the macro (you can use the ‘Select All’ button if you like) and paste it into the right-hand pane of the VBA editor ("Module1" window)

Press Alt+F11 again to go back to Excel

Optionally, press Alt+F8 to open the "Macro" dialog window. Select the macro, click ‘Options…’,  hold down the Shift key and type the letter A (or any other letter) and click ‘OK’. Then anytime you want to run the macro press Ctrl+Shift+A.

When you close the workbook you will need to save it as an xlsm or xls file if it’s not already one of those.
0
 
sasllcAuthor Commented:
I am using Excel 2010.  When I press Alt-F11 or Alt-F8, it just makes a "bing" tone but goes nowhere.  The screen does not change.  Any ideas?
0
 
sasllcAuthor Commented:
Ignore the last question...I found that solution.
0
 
Martin LissOlder than dirtCommented:
Did my code work for you?
0
 
sasllcAuthor Commented:
I will be testing it tonight.
0
 
sasllcAuthor Commented:
Worked great, thank you.
0
 
Martin LissOlder than dirtCommented:
You’re welcome and I’m glad I was able to help.

If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange MVE 2015
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.