Help with a Quicken macro

When I work in Quicken and download all of my credit card transactions from the bank, they come down in a format that I'd like to change. First of all, it's in all capitals, and I've got a macro to fix that.

The other problem is that the name of the vendor is always duplicated. Like this:

Here's another example:

What I would like is this:

One more example. Before:

And After:

The tricky part seems to be how to get rid of the duplicate vendor. Each vendor is a different length.

What I do now is manually delete the duplicate name from the beginning, then select the name of the vendor and the city and leave the state and the US alone. Then I apply title case to the area that I've selected.

What I would love is a Keyboard Macro to do all of this.

I've been using Keyboard Maestro casually for many years, but this feels way above my pay grade.

Any suggestions?

Does Quicken allow you to edit the Payee field? Do you just click in it, select the text, copy it, process it, then put it back? I don't think my own bank allows me to do that. It looks like the answer is yes, but I'm not sure.

And are you looking for a solution that you trigger after clicking in a field, or do you want the solution to find all the items on the page, even items that require scrolling down to see, and process them all autonomously?

This isn't a particularly difficult task, but it does depend upon your answers.

Hi Sleepy,

Thanks for the response.

Yes, Quicken allows you to edit that payee field. As you suggest, you can click in the field, copy the text out, process it, and put it back.

I’m not greedy. I’d be happy with a macro that I can invoke after I click in the field. The “title case” macro that I’ve already created is triggered after I select text in the field.

However, if there’s a version that looks for all of the items and finds them automatically, I’d try that, too.

The best part of getting these macros from others is that you can deconstruct them, see how they work, and modify them to your heart’s content. So, I’ll take anything.

Thanks again.


I'd be happy to help. I think I know what you want and I can handle the part that you call tricky. But I have another question. Is there a keystroke that moves you downwards into the next field? I'm trying to accomplish this without the mouse, which makes things easier, but I don't have your app to test. Can you come up with keystrokes that will let you edit a field, then proceed down to the next field and start editing without clicking the mouse?

One of the tricks up my sleeve is to use Title Case on everything and then "untitle" the last two items in the line (state and country.) It saves some work and should be very reliable. Another trick I have is to find the duplicate vendor name using a little search loop.

Since I haven't heard back from you, I went ahead and wrote a macro that seems to work. In this macro, I assume that the text has already been placed into the System Clipboard. So you may need to change that if you have placed the text into a variable. I would have liked to have automated the part where it includes the keys to go from one field to the next, but I haven't heard back from you on those questions, so I couldn't do that.

If you can't understand what I'm doing, I'm happy to explain. But you can probably learn something from this example regardless.

Basically, I locate the duplication by using a loop and breaking out of the loop when a duplicate is found. Then I use a little technique to split off the state/country and process the rest separately.

EDIT: OOPS, my two debug "Display actions" are still In this macro. You can delete any action that says "Display Text." They won't hurt, in fact they might help you understand the macro when you first run it, so maybe they might be informative. But ultimately you should delete them.

Remove Dupes and Capitalize Macro (v10.0.2)

Remove Dupes and Capitalize.kmmacros (6.8 KB)

No doubt there are other algorithms that can also accomplish the same result. I'm not saying mine is the best, but it's fairly easy to understand.

Thanks for taking the time.

I didn’t respond right away because Quicken is on my office computer, and I’m home for the night. I didn’t know for sure about which keystrokes are used to move between fields. I think that tab works.

But since I wasn’t sitting in front it the machine, I couldn’t be sure, so I thought I’d wait. I didn’t know that you’d be so fast!

Anyway, I’ll try the macro out in the morning, and report back.

Thanks again for your time and effort. I’ll report back.


No worries. I was kinda looking for something to do at that moment.

Hi Sleepy,

Okay, back at the work computer. I imported your macro, put it into the Quicken group, and assigned it a keystroke. When I invoke it, nothing happens.

Maybe you can walk me through what you're doing, and we can troubleshoot together. I tried to work it out for myself, but most of these steps are new stuff to me.

By the way, I tried to map out which keystrokes do what actions, as that might help you.

When you click on an item in the Quicken register, the whole line turns blue, registering that you are on that line. Then when you hit the enter button, it enters a text editing mode. The first thing that is highlighted is the date, and the tab key takes you over to the payee field. The first time that you go to the payee field, the whole text is selected, so that for example if you hit the backspace key, all of the text would be deleted.

Also, if you hit the left arrow key, the text is all deselected and the text insertion point travels to the beginning of the line. If you hit the right arrow key after you tab into this field, all of the text is deselected and the text insertion point travels to the end of the payee text.

The up arrow does nothing in this mode, and the down arrow selects from a drop down sheet with what Quicken thinks are potential matching transactions.

Hope this is of some help,


In order for my macro to work, you have to select (and copy) some text. My macro didn't include selecting text up to this point because I wasn't sure about the keystrokes we may need to do this.

Before we solve the keystroke issue, test my macro by putting sample text into the clipboard (usually done by selecting text, then pressing CMD-C). Then trigger my macro. (You can either assign a hotkey to my macro or press the TRY button if you know how to do that correctly.) Then paste the test into the field.

I know this is a lot of steps, but let me know if you are able to test this. Once we prove that my macro works, we will adjust its keys and triggers to make it work automatically.

Your efforts to describe the app's keystrokes are appreciated and should be helpful to make this macro really shine.

I need to run some errands, so I may not be around for an hour. But I await your reply.

Okay, progress! So I added some keystrokes to your macro to open the item for editing, tabbing to the correct field, copying the text, then running your code. Then I pasted the result and hit the enter key a couple of times to get out of the editing mode.

It didn't work, though, until I added pauses everywhere. I've done that a lot over the years when things don't work. So now, it's mostly working. There was one entry that I couldn't get to work, and I suspect that's because of the * before the second occurrence of the name.

If you'd like me to upload the revised version of your excellent work, I'll try to figure out how to do that. In the meantime, I'll try to shorten some of the pauses that I've added so that the macro still works, but takes less time.

However, it is working, and that's glorious.

You're quite the programmer. I'd love a walk through of what you did, because I'm still stumped.


I just read your post and have a couple of quick comments:

  1. I'm happy you've got it working; we may have to work on your "pauses";
  2. Some apps do require "pauses"; there are ways to handle that, but it sounds like you're managing;
  3. Yes, the asterisk in that example is a problem for my macro because you said the line started with a duplicate company name. Now we can see it's not strictly a duplicate, because there can be an asterisk (or other character?) between the duplicates. If you are sure that there can be only a SINGLE extra character, then I can fix the code fairly easily.
  4. I will consider helping you out with the keystrokes needed to jump from one line to the next, but I await your next comment before I start that.

I'm happy that it's working, too.

I know that there are alternatives to the "brute force" approach of pauses. They just take a little more time to develop and implement.

I can't be completely sure that there will be only one extra character. To be honest, this example with the * was a surprise to me. And, of course, since it's nearly impossible to account for every use case, and since a huge of time will be saved by using the macro in its current form, I don't mind occasionally having to do these by hand. it's the tedium of doing these over and over again that makes the macro so valuable. That said, if it's a fun challenge to try to cover more use cases, that's fine, too.

I'd also love a quick primer on what you are actually doing with your code, because it's still a bit opaque to me, and the more I know, the more I can customize it on my own.

Let me start by summarizing each action in English words.

  1. The For Each action says we are going to create a variable called LocalX that will start with the number 1 and go up to one-half the length of the characters in the clipboard. There's no point in going past that because if a vendor name is doubled, the start of the second name can't be past the half-way point.
  2. The first Substring action gets the first N characters of the fun field (which is in the clipboard)
  3. The second Substring action gets the second copy of the name (which has to start one character after the first copy of the vendor name; this would need to be modified to handle asterisks)
  4. The IF statement checks if there's a match.
  5. I there's a match, a new Substring is fetched that starts from the second copy of the vendor name and extends 999 characters (which should cover the maximum length of the field, right?) and there results are saved in the clipboard. This removes the first copy of the vendor name from the clipboard.
  6. The Search action splits the remaining clipboard into a single vendor name and a state/country string.
  7. You can delete the Display action.
  8. The first Filter action changes the Vendor name (Local1) to all lowercase.
  9. The second Filter action changes the Vendor name (Local1) to title case. (If the previous step was omitted, I think it wouldn't work on all caps words.)
  10. You can delete the Display aciton.
  11. The system clipboard is replaced by the new Vendorname (Local1) followed by a space followed by the state/country string (Local2)
  12. We break from the loop. This action could probably be omitted and the macro would still work, but why bother running if there will be no further match?

I'm happy to expand on any of these points if you tell me what you need help with.

Hi Sleepy,

Just wanted to let you know that I haven't forgotten. Thanks for your walkthrough. I'm going through your code item by item, and trying to understand what you're doing with each action. It's slow progress, but I'm getting there.

Your code is getting into an area of Keyboard Maestro that I've never delved into. It's fun, but also slow going. It feels like real programming.


Nice to hear that.

A couple of questions here, if I may. I think I understand the first 3 steps. Count the number of characters in the clipboard, divide by 2, then assign that value to LocalX. So LocalX is a number that represents half of the length of the string in the clipboard.

Then you grab the first half of the clipboard by getting a substring that starts at the first character and ends at the length represented by LocalX, which is half of the clipboard. So this is a way to get the first half of the system clipboard.

Then you grab the second half of the clipboard by getting a second substring that starts with LocalX+1 which is the first character of the second half of the clipboard and uses a length of LocalX, effectively getting the second half of characters in the clipboard.

So now you've got three variables, LocalX which the it the length of half of the clipboard, Local1 which is the first half of the clipboard, and Local2, which is the second half of the clipboard.

The next thing you do is to see if the variables match (in my case, they don't), and then if they do match, you do another set of steps.

What I don't understand is what happens if they don't match? I don't see where to logic goes if the strings don't match.

That's where I'm stuck.

One other thing: I'm having a difficult time in displaying the values of the variables. It's crucial to understanding what's going on, but it's hard to see what their values are at any given moment.
I can't get the Value Inspector to show them. If I do a "display briefly" I don't see it. If I do a "display in a new window", I get dozens of windows, which I then have to close. I've only been able to see them by doing "display in large text". There must be a better way.

For that matter, there must be a better way for me to debug your macro. I'm still searching.


If they don't match the loop continues with the number LocalX increasing until a match is found. If no match is found the loop ends and nothing at all happens.

Have I got a solution for you.

  1. Open the KM Debugger Window.
  2. Make sure the button in the upper right corner is set to white, not dark.
  3. Make sure the "Pause New Macros" flag is selected.
  4. When you launch the macro, you can step through the actions one at a time. And the variables will be displayed inside the window, like this:

NOTICE: the variables won't be displayed until they exist. That might be why you "didn't see them". Just keep clicking the button to execute the next action until they exist. You will see everything.

If you try my advice above, you will probably be very satisfied.

Hi @dbates

Maybe I'm missing something, but how come you don't just use Quicken for Mac's built in renaming rules for Payees. I would think that would solve this for you without needing to resort to KM macros. Not that I'm against using KM with Quicken. I have and extensive set of KM macros that I use with Quicken (Quicken 2017 for Mac Macros - #3 by RickO). But this seems to be one case where maybe KM isn't needed.

If you need help with Quicken's renaming rules usage, this forum is probably not the place to discuss that. If so, hop over here and post. I'm a "SuperUser" over there (username RickO) and I'd be glad to help out.

Hi Rick,

I already use Quicken's naming rules, but each rule takes time to set up. And there are hundreds and hundreds of different vendors in my credit card that I download from the bank. It seemed to me a lot of work to set up Quickfill rules for each and every one, considering that many of them I'll only see once.

That being said, I'll reach out to you on the Quicken forums, and maybe I can learn something. In the meantime, I'm having fun trying to decode Sleepy's text handling code.

1 Like