+ Reply to Thread
Results 1 to 5 of 5

Randbetween range based on cell values on different sheet

  1. #1
    Registered User
    Join Date
    10-16-2013
    Location
    Nederland
    MS-Off Ver
    Excel 2003
    Posts
    38

    Randbetween range based on cell values on different sheet

    Hello,

    I would like to return a random value from sheet "Sales Profit" where Country is the criteria. I tried something with the MATCH function, but that didn't work out for me.
    This is what I have so far (EU-version) :

    =INDEX('Sales Profit'!B:B;RANDBETWEEN(1;COUNTA('Sales Profit'!B:B)))

    In the attached example the random value for Bahrain would be somewhere in between 1-4, Belgium 5-71, etc.

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Randbetween range based on cell values on different sheet

    Its not very clear what you want, perhaps
    =RANDBETWEEN(MATCH(B2,'Sales Profit'!A:A,0),MATCH(B2,'Sales Profit'!A:A,0)+COUNTIF('Sales Profit'!A:A,'Random selection'!B2)-1

    return the row of the first match
    count the number of values that match
    random between (first match, first match + number of matches -1) then subtract 1 to get to your references

    uk version change the , for ;

  3. #3
    Registered User
    Join Date
    10-16-2013
    Location
    Nederland
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Randbetween range based on cell values on different sheet

    Sorry I wasn't very clear, however your post helped me out to fix the formula. I wanted to return the value in column B of the Sales profit sheet (text).

    This works for me:
    =INDEX('Sales Profit'!R:R;RANDBETWEEN(MATCH(B2;'Sales Profit'!L:L;0);MATCH(B2;'Sales Profit'!L:L;0)+COUNTIF('Sales Profit'!L:L;'Random selection'!B2)-1))

    Thanks a lot!

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: Randbetween range based on cell values on different sheet

    OR

    C2=INDEX(OFFSET(INDEX('Sales Profit'!B:B,MATCH(B2,'Sales Profit'!A:A,0)),,,COUNTIF('Sales Profit'!A:A,B2),),RANDBETWEEN(1,COUNTIF('Sales Profit'!A:A,B2)))
    OR

    =INDEX(INDEX('Sales Profit'!B:B,MATCH(B2,'Sales Profit'!A:A,0)):INDEX('Sales Profit'!B:B,MATCH(B2,'Sales Profit'!A:A,0)+COUNTIF('Sales Profit'!A:A,B2)-1),RANDBETWEEN(1,COUNTIF('Sales Profit'!A:A,B2)))
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  5. #5
    Registered User
    Join Date
    10-16-2013
    Location
    Nederland
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Randbetween range based on cell values on different sheet

    Also helpful, thank you!

+ 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. Find and update multiple sheet tabs with new data based on range of cell values.
    By robcgp1200 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-20-2017, 04:59 PM
  2. [SOLVED] Not creating "cycle" of PDFs of named range based on cell values in second sheet
    By Ochimus in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-27-2016, 02:12 AM
  3. Replies: 10
    Last Post: 07-03-2015, 04:29 PM
  4. [SOLVED] Copy Paste a Range of Values from a Different Sheet Based on Value Entered in Cell
    By hamidxa in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-13-2015, 04:53 PM
  5. [SOLVED] Randbetween to take numbers based on the cell values
    By harish.chinni in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-12-2013, 03:17 AM
  6. [SOLVED] Cell color based on its values for used range of a particular sheet by macro
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-04-2013, 01:22 AM
  7. Replies: 1
    Last Post: 07-19-2011, 08:31 AM

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