Optimizing advice on an academia reimbursement macro, add new variables only if needed and general advice?

Hi guys

so I have this macro I created to fill in prices of expenses for conferences, hotels flights etc for academia reimbursement in my institute. the macro (see below) outputs inputs into a apple numbers sheet to I can then easily get sums and breakdowns.

I would love to get any feedback and tips in general but the main questions I have is how to deal with some trips I have multiple category expenses (such as multiple hotels). do I need to create a new variable for each hotel I add the cost for?

how does one use additional variables (but only if needed) in a user input prompt?

can a variable auto increase the count number in the name (so var1, then the next input would be var2)?

or in general do I have it all wrong? is there a more efficient way to quick add numbers (expenses) to a spreadsheet or another (better?) app/approach

thx so much, looking forward to everyone's thoughts

best

Z

Is there a reason why you aren't just putting the data directly into Numbers? You could have a pop-up menu for your expenditure types, ensure that cells that required numbers got numbers, use Conditional Highlighting to flag errors/problems, etc -- and it would probably be quicker to enter data that way than via multiple prompts.

If you must use a macro, consider doing "one line per expenditure", just like a paper form. You'd only have one "collecting" variable in KM to which you'd append each expense gathered via your prompt. Separate your columns with tabs so the final text you pass to the AppleScript will be

Hotel<tab>2 nights<tab>300
Flight<tab>NY to London<tab>1800
Meal<tab>Dinner for 4 at Pizza Hut<tab>30
Entertainment<tab>Totally necessary, honest!<tab>500

...and you'll have an easier time looping by line and by tab-delimited item to pump the data into Numbers.

But it really depends on the data required in the expenses form.

Thx @Nige_S !

you mean dont use Keyboard Maestro at all but rather just numbers? what do you mean then by pop-ups menu? is that AppleScript for numbers or a native numbers macro system?

You'd only have one "collecting" variable in KM to which you'd append each expense gathered via your prompt.

any chance you can give an example of such collection mechanism in Keyboard Maestro ?

thx alot!

Z

It's a cell format in Numbers -- select the cell(s), show the Inspector, select Format, set Data Format to "Pop-Up Menu" and you can add values for people to choose from.

It's just an "Append Variable with Text" action, in your case appending the entries from the "Prompt for user input" dialog:

Prompt into text.kmmacros (4.9 KB)

Image

wow @Nige_S this is fantastic!

I guess the last part im still confused about is how do I then move the Tab delimited variable into numbers? (do I have to use AppleScript for that?).

perhaps to get summaries and totals I can just do it inside Keyboard Maestro and save it all as a markdown file for future reference? any thoughts?

thx again!!

Z

I can see a potential problem with adding line after line using Keyboard Maestro prompts. What if you miss-type a figure? You’re still going to have to double-check all the values in Numbers anyway so as @Nige_S is saying, why not just add the data directly into a Numbers spreadsheet (or any other spreadsheet like Excel or Google Sheets). After all, this is exactly what spreadsheet apps are for. And the big advantage of adding the data directly into Numbers is that you can do it in any order.

To answer that question, as @Nige_S's Macro saves the data with Tabs and Returns, you can actually paste it directly into Numbers and the data will spread across the various cells.

1 Like