Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 293
Default Press F2 with vba

Hey Joel,

Thanks for the reply.

I just tried SendKeys and could not get it to work consistently. Plus
the code was pasting contents of last cell - not what I need.

Here is what I tried (the first two cells only for this example):

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
Target.MergeArea.Activate
SendKeys "{F2}", True
If Target.MergeArea.Address = _
Range("pfCell_6").MergeArea.Address Then _
Range("pfCell_25").MergeArea.Select
If Target.MergeArea.Address = _
Range("pfCell_25").MergeArea.Address Then _
Range("pfCell_24").MergeArea.Select
....
End Sub

Any help to get this to work would be appreciated.

-Minitman


On Thu, 15 May 2008 03:08:01 -0700, Joel
wrote:

SendKeys Statement Example
This example uses the Shell function to run the Calculator application
included with Microsoft Windows. It uses the SendKeys statement to send
keystrokes to add some numbers, and then quit the Calculator. (To see the
example, paste it into a procedure, then run the procedure. Because
AppActivate changes the focus to the Calculator application, you can't single
step through the code.). On the Macintosh, use a Macintosh application that
accepts keyboard input instead of the Windows Calculator.

Dim ReturnValue, I
ReturnValue = Shell("CALC.EXE", 1) ' Run Calculator.
AppActivate ReturnValue ' Activate the Calculator.
For I = 1 To 100 ' Set up counting loop.
SendKeys I & "{+}", True ' Send keystrokes to Calculator
Next I ' to add each value of I.
SendKeys "=", True ' Get grand total.
SendKeys "%{F4}", True ' Send ALT+F4 to close Calculator.



"Minitman" wrote:

Greetings,

Is there anyway to press F2 inside of a macro with vba???

I can get my code to work if I manually press F2 after I hit enter.
But when I try to record it to see how vba interprets my keystrokes,
all it shows is this:

Range("AN5:AY5").Select
ActiveCell.FormulaR1C1 = "9/19/1981"
Range("BL5:BW5").Select
ActiveCell.FormulaR1C1 = ""

I hit Enter then F2. I did this twice in the sample above and this is
what gets recorded. In the first cell was a date and the second cell
was empty. I don't need to be copying or pasting over what is already
in the cell, I just need the ability to do so if needed.

Anyone have any ideas as to how to do this with vba?

Any help is always appreciated.

-Minitman


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
On Key press pokdbz Excel Programming 2 October 2nd 07 03:33 PM
When I Press the Enter Key Nothing happens. bigev Excel Discussion (Misc queries) 1 March 1st 06 03:05 PM
key press event? short_n_curly[_19_] Excel Programming 2 July 15th 05 08:43 PM
on press Fraggs[_18_] Excel Programming 1 June 7th 04 05:16 PM
test for key press Robert Chapman Excel Programming 6 October 6th 03 05:31 PM


All times are GMT +1. The time now is 11:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"