Vba beginner question

lynxmo

New Member
Joined
Mar 10, 2017
Messages
4
To dear all. In my vba task, I meet one question like the following. Hope someone can do me a favor.
Random uniform
1
2
3
4
5
6
7
8
9
10
11
12

<colgroup><col></colgroup><tbody>
</tbody>



0,964274899
0,038850448
0,266376936
0,740520709
0,963839292
0,256455657
0,087700616
0,392575932
0,459835397
0,824301717
0,953287091
0,392802765

<colgroup><col></colgroup><tbody>
</tbody>

Rand()
Normal number0,340821459

<tbody>
</tbody>

And then in the vba part
That is the macro will sum 12 uniform random numbers and then will substract 6 to the sum and return the result which is a normal random number.
The result should be in the following table.
BC
Normal numbers
1
2
3
4
5
6
7
8
9
10

<colgroup><col></colgroup><tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
are you doing this many times and producing a histogram

generate 12 numbers add them subtract 6 is easy to understand and will give numbers clustered around zero

your second part - what are the numbers 1 to 10 ?
 
Upvote 0
are you doing this many times and producing a histogram

generate 12 numbers add them subtract 6 is easy to understand and will give numbers clustered around zero

your second part - what are the numbers 1 to 10 ?

I will send the picture. it will be clear.
17157401_622555874617159_8328867917163319982_o.jpg
17097851_622556754617071_3714080783750229819_o.jpg
 
Upvote 0
you just put =rand() in 12 cells, total them, subtract 6 from the total....

It's just for the question 1. And the question 3 should be in the VBA...
I Know the excel formula,But I need the marco function.
Thanks anyway:)
 
Upvote 0
for j=1 to 12
sum=sum+rnd
next j
mynumber=sum-6
cells(1,1)=mynumber
end sub

make sure you understand this rather than just copy it or you will not really learn excel....and there are more modern vba commands - what have you been taught ? eg the "with" command.........
 
Upvote 0
for j=1 to 12
sum=sum+rnd
next j
mynumber=sum-6
cells(1,1)=mynumber
end sub

make sure you understand this rather than just copy it or you will not really learn excel....and there are more modern vba commands - what have you been taught ? eg the "with" command.........

Thanks so much.
Because at first I use the sub normalnumber() as the follow:
[FONT=&quot]range("C30:C39")=WorksheetFunction.Sum(Range("C5:C16"))-6

Thanks

[/FONT]
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top