Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default macros randbetween formulas

i would like to make a "button" on the spreed sheet it self were every time i
press it, it runs the Randbetween formual and place it in a cell, one is this
possable and can someone show me what i got to do, compleatly have not idear
how to wright mircos thanks
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 245
Default macros randbetween formulas

It is possible but you have to be more specific about your needs. At
present, all I can work out is that you want a button to enter a
Randbetwee(0 formula in an unspecified blank cell. For example, how does the
function get its values; which blank cell?

When you give further detail, think of yourself in the position of somebody
who knows absolutely nothing about your project and needs.

This may give you a start:

Sub test()

' Get input from user:
vFirst = InputBox("enter smaller value")
vLast = InputBox("enter larger value")

'write a Randbetween formula in the selected cell:
Selection.Formula = "=Randbetween(" & vFirst & "," & vLast & ")"

End Sub


--
Steve

"Roadrunner_Ex" wrote in message
...
i would like to make a "button" on the spreed sheet it self were every
time i
press it, it runs the Randbetween formual and place it in a cell, one is
this
possable and can someone show me what i got to do, compleatly have not
idear
how to wright mircos thanks


  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 2
Default macros randbetween formulas

thats correct thats what i would like to happon, the values i want it to
grearate is between 1 and 20 and i don't know which cell yet because i did
not know it was possable, but lets just say cell A1 for know. its all for a
paper to game that i play so i need excell to genrate an number between one
and 20 in to an cell then that number can be use in a simple addition formula
but i won't the random number to change ever time i click the "button" to
give an new number between 1 and 20 and so on, i hope thats a clear idear i
would like to happon, please if this dose not help ill try to again to
explane thanks.

"AltaEgo" wrote:

It is possible but you have to be more specific about your needs. At
present, all I can work out is that you want a button to enter a
Randbetwee(0 formula in an unspecified blank cell. For example, how does the
function get its values; which blank cell?

When you give further detail, think of yourself in the position of somebody
who knows absolutely nothing about your project and needs.

This may give you a start:

Sub test()

' Get input from user:
vFirst = InputBox("enter smaller value")
vLast = InputBox("enter larger value")

'write a Randbetween formula in the selected cell:
Selection.Formula = "=Randbetween(" & vFirst & "," & vLast & ")"

End Sub


--
Steve

"Roadrunner_Ex" wrote in message
...
i would like to make a "button" on the spreed sheet it self were every
time i
press it, it runs the Randbetween formual and place it in a cell, one is
this
possable and can someone show me what i got to do, compleatly have not
idear
how to wright mircos thanks



  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 245
Default macros randbetween formulas

As I now understand it, you wish to generate a random number that holds its
value between clicks of a button.

VBA does not have access to Randbetween(). If you need to set a number with
different upper and lower limits:

Sub genRand()
lower = 1 'change
upper = 20 ' change
Randomize
Sheets("Sheet1").Range("A1").Value = Int((upper - lower + 1) * Rnd() +
lower)
'change Sheet1 and A1
End Sub

If you wish to get your upper and lower limits from cells (say, in a sheet
named 'Gamevariables'), instead of hard-coding values you can set upper and
lower this way:
lower = Sheets("Gamevariables").Range("A2").Value
upper = Sheets("Gamevariables").Range("A3").Value


If your lower limit is always 1, the simpler version:
Sub genRand()
Randomize
Sheets("Sheet1").Range("A1").Value = Int(Rnd() * 20) + 1

End Sub






--
Steve

"Roadrunner_Ex" wrote in message
...
thats correct thats what i would like to happon, the values i want it to
grearate is between 1 and 20 and i don't know which cell yet because i did
not know it was possable, but lets just say cell A1 for know. its all for
a
paper to game that i play so i need excell to genrate an number between
one
and 20 in to an cell then that number can be use in a simple addition
formula
but i won't the random number to change ever time i click the "button" to
give an new number between 1 and 20 and so on, i hope thats a clear idear
i
would like to happon, please if this dose not help ill try to again to
explane thanks.

"AltaEgo" wrote:

It is possible but you have to be more specific about your needs. At
present, all I can work out is that you want a button to enter a
Randbetwee(0 formula in an unspecified blank cell. For example, how does
the
function get its values; which blank cell?

When you give further detail, think of yourself in the position of
somebody
who knows absolutely nothing about your project and needs.

This may give you a start:

Sub test()

' Get input from user:
vFirst = InputBox("enter smaller value")
vLast = InputBox("enter larger value")

'write a Randbetween formula in the selected cell:
Selection.Formula = "=Randbetween(" & vFirst & "," & vLast & ")"

End Sub


--
Steve

"Roadrunner_Ex" wrote in
message
...
i would like to make a "button" on the spreed sheet it self were every
time i
press it, it runs the Randbetween formual and place it in a cell, one
is
this
possable and can someone show me what i got to do, compleatly have not
idear
how to wright mircos thanks



  #5   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 2
Default macros randbetween formulas

Tried it to day and works like a dream thanks for your help!

"AltaEgo" wrote:

As I now understand it, you wish to generate a random number that holds its
value between clicks of a button.

VBA does not have access to Randbetween(). If you need to set a number with
different upper and lower limits:

Sub genRand()
lower = 1 'change
upper = 20 ' change
Randomize
Sheets("Sheet1").Range("A1").Value = Int((upper - lower + 1) * Rnd() +
lower)
'change Sheet1 and A1
End Sub

If you wish to get your upper and lower limits from cells (say, in a sheet
named 'Gamevariables'), instead of hard-coding values you can set upper and
lower this way:
lower = Sheets("Gamevariables").Range("A2").Value
upper = Sheets("Gamevariables").Range("A3").Value


If your lower limit is always 1, the simpler version:
Sub genRand()
Randomize
Sheets("Sheet1").Range("A1").Value = Int(Rnd() * 20) + 1

End Sub






--
Steve

"Roadrunner_Ex" wrote in message
...
thats correct thats what i would like to happon, the values i want it to
grearate is between 1 and 20 and i don't know which cell yet because i did
not know it was possable, but lets just say cell A1 for know. its all for
a
paper to game that i play so i need excell to genrate an number between
one
and 20 in to an cell then that number can be use in a simple addition
formula
but i won't the random number to change ever time i click the "button" to
give an new number between 1 and 20 and so on, i hope thats a clear idear
i
would like to happon, please if this dose not help ill try to again to
explane thanks.

"AltaEgo" wrote:

It is possible but you have to be more specific about your needs. At
present, all I can work out is that you want a button to enter a
Randbetwee(0 formula in an unspecified blank cell. For example, how does
the
function get its values; which blank cell?

When you give further detail, think of yourself in the position of
somebody
who knows absolutely nothing about your project and needs.

This may give you a start:

Sub test()

' Get input from user:
vFirst = InputBox("enter smaller value")
vLast = InputBox("enter larger value")

'write a Randbetween formula in the selected cell:
Selection.Formula = "=Randbetween(" & vFirst & "," & vLast & ")"

End Sub


--
Steve

"Roadrunner_Ex" wrote in
message
...
i would like to make a "button" on the spreed sheet it self were every
time i
press it, it runs the Randbetween formual and place it in a cell, one
is
this
possable and can someone show me what i got to do, compleatly have not
idear
how to wright mircos thanks





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros and Formulas Daniel Excel Worksheet Functions 4 August 14th 08 08:35 PM
Can I insert formulas into my macros? Sarah Excel Discussion (Misc queries) 3 April 3rd 08 01:07 PM
using formulas in macros BBEXCELNOVICE Excel Discussion (Misc queries) 4 November 12th 06 10:03 AM
formulas vs macros excelFan Excel Discussion (Misc queries) 4 March 23rd 06 01:45 PM
Macros/Formulas Michelle Excel Worksheet Functions 2 October 26th 05 04:26 PM


All times are GMT +1. The time now is 09:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"