Execute vba code on cell exit

  • Thread starter Bill (Unique as my name)
  • Start date
B

Bill (Unique as my name)

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!
 
J

JE McGimpsey

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
 
D

Dave Peterson

See another suggestion at your other post.

Bill (Unique as my name) said:
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top