Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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
  • 343 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