[Solved] Random name picker by macro

Discuss the spreadsheet application
Post Reply
davmar
Posts: 1
Joined: Sun Mar 03, 2024 6:18 pm

[Solved] Random name picker by macro

Post by davmar »

Hi all,

I want to choose a name at random from a list.
I was able to get the formula that makes this selection possible.
Now I'd like it to be a macro and a button. On which I can press and display the result.
How do I implement this by macro and set up the button?
Also, is it possible in the formula for the number of rows to be infinite, but not limited to a given range of rows?

Thanks,
Attachments
123.ods
(14.95 KiB) Downloaded 36 times
Last edited by MrProgrammer on Mon Mar 11, 2024 10:15 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved] Example provided -- MrProgrammer, forum moderator
OpenOffice 4.1.12 on Windows 10
User avatar
MrProgrammer
Moderator
Posts: 4909
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Random Name Picker by macro

Post by MrProgrammer »

davmar wrote: Sun Mar 03, 2024 6:33 pm I want to choose a name at random from a list.
[Tutorial] Randomization in Calc
This attachment demonstrates how to do that. When you want to choose a new name press Ctrl+Shift+F9 (⌘⇧F9 on Mac) and then copy the number (not the formula) from D2 to C2.
202403031120.ods
(23.83 KiB) Downloaded 27 times

davmar wrote: Sun Mar 03, 2024 6:33 pm Now I'd like it to be a macro.
Just record a macro to perform those steps.
• Tools → Macros → Record Macro
• Press Ctrl+Shift+F9    (⌘⇧F9 on Mac)
• Click cell D2 in my attachment
• Edit → Copy
• Click cell C2
• Edit → Paste Special → Selection:Numbers (only) → Options:None → Operations:None → ShiftCells:Don't → OK
• Stop Recording
• Give your macro a name and save it

To run your macro use Tools → Macros → Run Macro.
[Tutorial] Favorite Recorded Calc Macros

davmar wrote: Sun Mar 03, 2024 6:33 pm… and a button
Button controls are a nuisance in Calc, but if you want you can use a toolbar button.
[Tutorial] Binding a macro: Shortcut key, menu or toolbar

davmar wrote: Sun Mar 03, 2024 6:33 pm [Is] it possible in the formula for the number of rows to be infinite?
No spreadsheet supports an infinite number of rows. My attachment allows for 1000 names, which you can increase if needed.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the Subject field. Select the green checkmark icon at the same time.

[Tutorial] Ten concepts that every Calc user should know
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
FJCC
Moderator
Posts: 9284
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Random Name Picker by macro

Post by FJCC »

As currently set up, the cell C3 in 123.odt will display a new name every time you press Ctrl + Shift + F9. Is that all you want from a button and macro?
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Post Reply