+ Reply to Thread
Results 1 to 5 of 5

Get parameters inside Randbetween

Hybrid View

  1. #1
    Registered User
    Join Date
    02-13-2014
    Location
    Malta
    MS-Off Ver
    Excel 2007
    Posts
    2

    Get parameters inside Randbetween

    Hi,

    I am using randbetween function and giving two values such as -10,10. Is there a function that I could use which tells me which values are being given inside this function please? For example in this case it will tell me that the values/parameters are -10 and 10. Thanks

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Get parameters inside Randbetween

    You could put them in separate cells:

    =randbetween(A1, A2)
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Get parameters inside Randbetween

    Here come the overkill solution:

    A little UDF does the job:
    Public Function RandArg(c As Range, Optional ArgType As Integer)
    Dim lLow As Long, lHigh As Long
    On Error GoTo FuncErr
    If InStr(1, c.Formula, "RANDBETWEEN") = 0 Then
        RandArg = CVErr(xlErrName)
    Else
        lLow = Left(Split(c.Formula, "(")(1), InStr(1, Split(c.Formula, "(")(1), ",") - 1)
        lHigh = Left(Split(c.Formula, ",")(1), InStr(1, Split(c.Formula, ",")(1), ")") - 1)
        Select Case ArgType
            Case 1:   RandArg = lLow
            Case 2:   RandArg = lHigh
            Case Else:  RandArg = "(" & lLow & "," & lHigh & ")"
        End Select
    End If
    Exit Function
    FuncErr:
        RandArg = CVErr(xlErrValue)
    End Function
    Useage
    With the following formula in cell A1:
    Formula: copy to clipboard
    =RANDBETWEEN(-10,10)


    B
    C
    1
    Formula
    Result
    2
    =randarg(A1,1)
    -10
    3
    =randarg(A1,2)
    10
    4
    =randarg(A1)
    (-10,10)
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  4. #4
    Registered User
    Join Date
    02-13-2014
    Location
    Malta
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Get parameters inside Randbetween

    Thanks Olly it was exactly what I was searching for :D you made my day :-D

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Get parameters inside Randbetween

    Quote Originally Posted by mat 1_8 View Post
    Thanks Olly it was exactly what I was searching for :D you made my day :-D
    Glad it helped - thanks for the feedback Nice to see a poster from Malta!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 10-02-2012, 04:27 PM
  2. Finding data inside an Excel Table using two parameters of search
    By drsteffa in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-04-2012, 08:54 AM
  3. Help using RANDBETWEEN
    By retghy in forum Excel General
    Replies: 13
    Last Post: 08-02-2009, 06:54 PM
  4. Randbetween
    By foad in forum Excel General
    Replies: 2
    Last Post: 03-25-2009, 04:03 PM
  5. [SOLVED] RANDBETWEEN
    By Michel AUDIFFREN in forum Excel General
    Replies: 0
    Last Post: 02-26-2006, 07:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1