Press and hold doesn't hold?

Hi, I am trying to build what seemed to me a pretty simple Macro but I can't seem to get it right. Here's what I'm trying to do.

I have a very big Excel document and I need to either delete sequences of 4 cells and shift cells up or do an insert and shift cells down.

Since this is quite tedious, I was trying to build a macro that does the following (see image):

28

This was only the beginning. After that, I wanted to insert a delete instruction and then select shift cells up from the menu. Before building the whole macro, though, I wanted to test if this did what I wanted. It doesn't.

When I execute this part of the macro, the cursor simply moves 4 cells to the right but it doesn't select the four cells which is what I wanted to accomplish before continuing with the rest of the macro.

Can anybody enlighten me and tell me what I'm doing wrong? I thought this was a very simple macro and something Keyboard Maestro could do very easily. I'm stumped, though. Can anybody tell me what are the actions that I should use to do what I'm trying to do?

Thanks in advance.

JM

Hi JM,

Just to quickly answer your most pressing question, you can have KM perform the keystrokes you want by pressing Shift-Right Arrow in the Type a Keystroke action directly, and repeat it four times:

image

In addition to gglick's good suggestion, I'd recommend getting rid of the click at 0,0 in the current window. It shouldn't help you in any way, and might cause unintended effects.

Excel is very scriptable, using either Excel VBA or AppleScript.
Rather that simulating the UI with KM, I'd suggest that you script the changes you want.
There is a lot of information and examples available for scripting Excel.

Let us know if you'd like more information.

Thanks everybody for your quick responses! Sorry about not acknowledging them earlier. I had to go away for the weekend and I didn't see them until now.

I followed gglick and Vincent's advice and that did help because now I'm able to get the selection of the cells that I wanted to select. Alas, I'm stuck again because now I need to do something that requires clicking the mouse button and selecting an item in the menu but I'm stumped again.

I remember trying this in the past and I remember it was quite complicated.

JMichaelTX is completely right in saying that using scripting is more sensible for this kind of task. The problem is that I'm not familiar with any of these scripting languages. This is the reason I got KM. I thought I would be able to avoid scripting.

I think it might be time to stop being lazy and learn some scripting since it is clear that it might be useful for this and other possible problems in the future. The truth, though, is that I'm pretty busy and I don't have time to do a lot of reading right now.

So the answer is yes, please, tell me where I can start in order to use scripting with KM. If anybody could point to some resources that could be useful for someone with very little idea about these scripting languages, I would appreciate it. I think I would prefer to try AppleScript as I use a Mac and it might help me with other stuff besides Excel.

Learning AppleScript

If you are new to AppleScript and are interested in learning more, then I'd suggest you take a look at:

  1. AppleScript: Beginner's Tutorial
  2. Script Debugger 7 -- a full IDE for developing AppleScript.
    SD7 now comes with a 20-day free trial, and then will gracefully downgrade to the FREE SD7 Lite (which is still much better than Script Editor).
  3. Using AppleScript to Get and Set KM Variables
  4. Execute an AppleScript action

You can get lots of AppleScript help here in this forum, and in the Script Debugger Forum.

Learning Excel AppleScript

  • Excel VBA Macros to AppleScript -- written a few years ago to facilitate moving from VBA to AppleScript, this is still one of the most exhaustive guides to using AppleScript with Excel
  • A Google Search on "AppleScript Excel" will return many hits, many examples
  • Using SD7 as your script editor and IDE will be really helpful to learning and exploring the Excel scripting model.
  • There are also a number of good examples of scripting Excel here in the KM Forum.

OK. Thank you!

Josep M.