Page 1 of 1

[Solved] Random name picker by macro

Posted: Sun Mar 03, 2024 6:33 pm
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,

Re: Random Name Picker by macro

Posted: Sun Mar 03, 2024 7:47 pm
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 73 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

Re: Random Name Picker by macro

Posted: Sun Mar 03, 2024 8:00 pm
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?