View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Creating what should be a simple macro

Let's start with the HOME. Say we want to enter the character Z in that
first column

Sub dwight()
Application.SendKeys "{ENTER}"
DoEvents
Application.SendKeys "{F2}"
Application.SendKeys "{ENTER}"
DoEvents
Application.SendKeys "{HOME}"
DoEvents
Application.SendKeys "{F2}"
Application.SendKeys "Z"
Application.SendKeys "{ENTER}"
DoEvents
End Sub

Here's what's happening:
1. the HOME gets us back to column A
2. the DoEvents make sure Excel is ready to receive data
3. the F2 put the cell in edit mode
4. the "Z" dumps Z into the cell
5. the ENTER completes the entry
6. the final DoEvents makes sure that Excel has processed steps 3,4,5

That's why the DoEvents is so important:

Sendkeys is like pitching softballs. DoEvents allows the catcher to catch
the balls.
--
Gary''s Student - gsnu200715


"Dwight" wrote:

I put that in and had one too many returns, so I took one out.

After it does the line down, the F2 and the Home, I need to enter one
character at the front of the cell then turn it off.

It works great until I want it to turn off then it deletes what I typed and
sits at the front of that cell blinking.

I need it to either stop after my character I imput or take the first
character from the cell to it's left and add it on the front for me in a loop.

Now what?

"Gary''s Student" wrote:

Sub dwight()
Application.SendKeys "{ENTER}"
DoEvents
Application.SendKeys "{F2}"
Application.SendKeys "{ENTER}"
DoEvents
Application.SendKeys "{HOME}"
End Sub

You may need to back up a row.
--
Gary''s Student - gsnu200715


"Dwight" wrote:

I want to create a macro that will start in the current cell, give a carriage
return to go to the cell below, give a F2 keystroke, then a Home keystroke
and end.

I know this is very basic, but I can't seem to get it to work.

Any assistance will be greatly appreciated.