Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

VBA Excel problems!


  • Please log in to reply

#1
RRR2006

RRR2006

    New Member

  • Member
  • Pip
  • 1 posts
Hi!


All i wana do is create a random block of numbers in a designated range.

Ive done this but it fill the WHOLE range with one random number. So I want to fill each cell in the range with a different random number....

Any ideas?! :whistling:




Sub RandomNumbers()

'Makes a list of Random Numbers
'Shortcut is CTRL-SHFT-R

Dim I As Integer
Dim myRange As Range
For I = 0 To 25
Set myRange = Range("C3:G7")
myRange.Value = Int(Rnd * 100) + 1
myRange.Offset(1, 0).Range("A1").Select
Next I

End Sub



Many Thanks!
  • 0

Advertisements


#2
nollijible

nollijible

    Member

  • Member
  • PipPip
  • 25 posts
Nobody tried this yet?
Give this a whirl...

Range("C3:G7").Formula = "=Int(Rand() * 100) + 1"

Since each cell will pick it's own random number between 1 and 100, you may get duplicates.
Note, you'll probably want to precede this with "Randomize" to keep the same numbers from showing all the time

Edited by nollijible, 27 March 2007 - 08:01 PM.

  • 0

#3
diggeryo

diggeryo

    Member

  • Member
  • PipPipPip
  • 354 posts
I came across this Excel add-in a couple of weeks ago: http://www.ablebits....ddins/index.php

It does what you want and more. It doesn't say it specifically works with Excel 2007, but it seems to do so without any problems.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP