randomize


D

dallas

Sub randomize()
Range("H2") = Int((Range("B4") - Range("B3") + 1) * Rnd + Range("B3")

End Sub

I want to randomize from more than "B4 - B3".

"B4 - B3" and "C4 - C3" and "D4 - D3" and "E4 - E3"

and get the rnd result in "H2
 
Ad

Advertisements

A

Auric__

Sub randomize()
Range("H2") = Int((Range("B4") - Range("B3") + 1) * Rnd + Range("B3"))

End Sub

I want to randomize from more than "B4 - B3".

"B4 - B3" and "C4 - C3" and "D4 - D3" and "E4 - E3"

and get the rnd result in "H2"

Two things:

1) Randomize is a keyword - use something else for the name of your sub.

2) What is your question? You seem to have a good idea of what to do.
 
P

Peter Atherton

Hi

I Think this might be what you want
Sub Test()
Dim tot As Double, c As Variant
i = 3
randomize
For j = 2 To 7
c = Int(Cells(i + 1, j) - Cells(i, j) + 1 * Rnd + Cells
(i, j))
tot = tot + c
Next
Range("H2").Value = tot
End Sub

(e-mail address removed)

regards
Peter
 
T

Tom Ogilvy

Sub myrandomize()
Dim rng as Range, rng1 as Range
Dim idex as Long

Set rng = Range("B3:E3")
Set rng1 = Range("B4:E4")
idex = Int(Rnd() * 4 + 1)
Range("H2") = Int((rng1(idex) - rng(idex) + 1) _
* Rnd + rng(idex))

End Sub

Might do what you want.
 
Ad

Advertisements

F

Frank Kabel

Hi
sure is it o.k. :)
Michael and 'keepitcool' were just joking as Tom's suggestion nearly
always work perfectly (and if you stay for some weeks in this NG you
will surely recognize this)

So just stay, read, post and enjoy
 
A

Auric__

Hi
sure is it o.k. :)
Michael and 'keepitcool' were just joking as Tom's suggestion nearly
always work perfectly (and if you stay for some weeks in this NG you
will surely recognize this)

"Nearly"? I've *never* seen one of his fixes *not* work.
 
M

Michael Hopwood

Hello dallas,

We were just having a light-hearted moment there, if you see <g> in a post
it means "grin" as when you are having a bit of a joke you would have a grin
on your face.

Welcome to the newsgroups!
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top