Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default macro to set bottom and top values for randbetween

I want to select a cell or a range of cells, then fill it with randbetween numbers. The bottom and top values will vary from time to time. How can I accomplish this. Maybe have an input box appear where the user could enter the bottom/top values, or designate 2 cells where the user could input the values, invoke the macro, and have it refer to those 2 cells to get the bottom/top values?

Thanks!

Tonso
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default macro to set bottom and top values for randbetween

hi Tonso,

i suppose the values are in range("A1") and range("B1")

x = Evaluate("randbetween(" & [A1] & "," & [B1] & ")")

--
isabelle



Le 2012-10-03 10:22, Tonso a écrit :
I want to select a cell or a range of cells, then fill it with randbetween numbers.


The bottom and top values will vary from time to time. How can I accomplish this.

Maybe have an input box appear where the user could enter the bottom/top values, or

designate 2 cells where the user could input the values, invoke the macro, and have it refer to those 2 cells to get the bottom/top values?

Thanks!

Tonso

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default macro to set bottom and top values for randbetween

On Wednesday, October 3, 2012 10:22:17 AM UTC-4, Tonso wrote:
I want to select a cell or a range of cells, then fill it with randbetween numbers. The bottom and top values will vary from time to time. How can I accomplish this. Maybe have an input box appear where the user could enter the bottom/top values, or designate 2 cells where the user could input the values, invoke the macro, and have it refer to those 2 cells to get the bottom/top values? Thanks! Tonso


isabelle,

Thank you very much!!

tonso
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default macro to set bottom and top values for randbetween

On Wednesday, October 3, 2012 10:22:17 AM UTC-4, Tonso wrote:
I want to select a cell or a range of cells, then fill it with randbetween numbers. The bottom and top values will vary from time to time. How can I accomplish this. Maybe have an input box appear where the user could enter the bottom/top values, or designate 2 cells where the user could input the values, invoke the macro, and have it refer to those 2 cells to get the bottom/top values? Thanks! Tonso


Isabelle,
The macro works great if a single cell is selected. If more than 1 cell is selected, the value in eery cell is the same. I need to have a different value returned for each cell selected, whether it is a singel cell, or serveral or more cells.

Thanks,

Tonso
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default macro to set bottom and top values for randbetween

Hi Tonso,

Am Wed, 3 Oct 2012 08:16:55 -0700 (PDT) schrieb Tonso:

The macro works great if a single cell is selected. If more than 1 cell is selected, the value in eery cell is the same. I need to have a different value returned for each cell selected, whether it is a singel cell, or serveral or more cells.


try it with:

Selection.Formula = "=randbetween(" & [A1] & "," & [B1] & ")"


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default macro to set bottom and top values for randbetween

two possibilities,

Sub test1()
For Each c In Selection
Range(c.Address) = Evaluate("randbetween(" & [A1] & "," & [B1] & ")")
Next
End Sub

Sub test2()
'version without doubloon
Dim v As Integer, i As Integer
Set dico = CreateObject("Scripting.Dictionary")
Do Until i = [B1] - [A1] + 1
v = Int(([B1] - [A1] + 1) * Rnd() + [A1])
If Not dico.Exists(v) Then
dico.Add v, v
i = i + 1
End If
Loop
[A2].Resize(i) = Application.Transpose(dico.items)
End Sub


--
isabelle


Le 2012-10-03 11:16, Tonso a écrit :

Isabelle,
The macro works great if a single cell is selected.


If more than 1 cell is selected, the value in eery cell is the same.

I need to have a different value returned for each cell selected, whether it is a singel cell, or serveral or more cells.

Thanks,

Tonso

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default macro to set bottom and top values for randbetween

On Wednesday, October 3, 2012 10:22:17 AM UTC-4, Tonso wrote:
I want to select a cell or a range of cells, then fill it with randbetween numbers. The bottom and top values will vary from time to time. How can I accomplish this. Maybe have an input box appear where the user could enter the bottom/top values, or designate 2 cells where the user could input the values, invoke the macro, and have it refer to those 2 cells to get the bottom/top values? Thanks! Tonso


Isabelle, Claus,

Thank you both so much for your expert help!!
Sincerely,
Tonso
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
average out of bottom 10 values picks72 Excel Worksheet Functions 6 August 5th 09 05:19 PM
Getting x axis values on bottom in a logarithmic scale chart Steven Excel Discussion (Misc queries) 2 June 12th 07 06:46 PM
Column Values Re-Order Bottom to Top Jerry Pio Excel Worksheet Functions 2 February 10th 06 02:16 PM
3d Graph Show Values at Bottom Job Excel Worksheet Functions 1 May 7th 05 06:04 PM
transposing values top to bottom Ted Metro Excel Discussion (Misc queries) 3 April 18th 05 03:10 PM


All times are GMT +1. The time now is 08:15 PM.

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

About Us

"It's about Microsoft Excel"