+ Reply to Thread
Results 1 to 6 of 6

In need of marital status function

  1. #1
    Registered User
    Join Date
    09-26-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    21

    In need of marital status function

    Hello all,
    Can anyone help me write a function for a randomly generated marital status (M,S)?

    Thanks....

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: In need of marital status function

    For Excel 2007 and higher:
    Please Login or Register  to view this content.
    The same formula can be used in Excel 2003 and lower, but you'll have to enable the Analysis Toolpak Addin
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: In need of marital status function

    try :
    =If(Randbetween(1,2)=1,"M","S")

    Hopethis helps
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: In need of marital status function

    If you don't want to use RANDBETWEEN(), which is why the Analysis Toolpak is necessary, you can use this instead:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-17-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: In need of marital status function

    This isn't something that needs to be done through VBA. You can place the formula below in whichever cell(s) that you want the randomly generated marital status. However, once you have them placed in all the cells that you want, I would copy all the cells and paste special values to remove the formula because it will constantly change between S and M as someone edits any cell in the file.

    Please Login or Register  to view this content.
    Edit:
    Sorry for essentially posting the same code. I thought my page refreshed to see if there were any posts but I guess it didn't.

  6. #6
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: In need of marital status function

    Another way..

    =CHOOSE(INT(RAND()*2)+1,"M","S")
    Life's a spreadsheet, Excel!
    Say thanks, Click *

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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