Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Execute vba code on cell exit

I came up with this much, but it does nothing. Help me please?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static Oldselection As Range
If Oldselection = "Meter Reading" Then
SendKeys "{RIGHT 2}Bill Coyne{RIGHT}FM", True
End If
End Sub

I want to fill in "Bill Coyne" two cells to the right and "FM" three
cells to the right if the cell I exit equals "Meter Reading"

Thank you!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Execute vba code on cell exit

One way:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Static rOldSelection As Range
If Not rOldSelection Is Nothing Then _
If rOldSelection.Text = "Meter Reading" Then _
rOldSelection.Offset(0, 2).Resize(1, 2).Value = _
Array("Bill Coyne", "FM")
Set rOldSelection = Target
End Sub


In article . com,
"Bill (Unique as my name)" wrote:

I came up with this much, but it does nothing. Help me please?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static Oldselection As Range
If Oldselection = "Meter Reading" Then
SendKeys "{RIGHT 2}Bill Coyne{RIGHT}FM", True
End If
End Sub

I want to fill in "Bill Coyne" two cells to the right and "FM" three
cells to the right if the cell I exit equals "Meter Reading"

Thank you!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Execute vba code on cell exit

See another suggestion at your other post.

"Bill (Unique as my name)" wrote:

I came up with this much, but it does nothing. Help me please?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static Oldselection As Range
If Oldselection = "Meter Reading" Then
SendKeys "{RIGHT 2}Bill Coyne{RIGHT}FM", True
End If
End Sub

I want to fill in "Bill Coyne" two cells to the right and "FM" three
cells to the right if the cell I exit equals "Meter Reading"

Thank you!


--

Dave Peterson
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
Execute vba code on cell exit Bill (Unique as my name) Excel Discussion (Misc queries) 2 May 24th 07 03:48 PM
code to execute on enter sc Excel Programming 2 March 19th 07 06:10 PM
How can I use VB code to execute macro when double-clicking cell? JDay01 Excel Programming 2 June 13th 06 03:12 PM
Execute Code gti_jobert[_48_] Excel Programming 2 March 2nd 06 09:37 AM
Code won't execute... Jim Cone Excel Programming 1 August 20th 05 07:22 AM


All times are GMT +1. The time now is 05:29 PM.

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

About Us

"It's about Microsoft Excel"