ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   action on lostfocus in a cell (https://www.excelbanter.com/excel-programming/343101-action-lostfocus-cell.html)

Einar[_2_]

action on lostfocus in a cell
 
Hi NG

I've tried to make a Excel VBA macro to take the value from a cell - cell
M3 - when focus is leaving that cell, but I'm not able to do that :-(

Any one in here, who can help me plz





JNW

action on lostfocus in a cell
 
You'll probably need to use the selectionChange event in the worksheet. I
don't know how to check if M3 was active before the selection change.

You could try something like:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("M3").copy
Range("A1").PasteSpecial
Application.CutCopyMode = False
End Sub

"Einar" wrote:

Hi NG

I've tried to make a Excel VBA macro to take the value from a cell - cell
M3 - when focus is leaving that cell, but I'm not able to do that :-(

Any one in here, who can help me plz






Executor

action on lostfocus in a cell
 
Hi to all

This is a step in correct direction.

Try this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static oldRange As Range
If Not oldRange Is Nothing Then
If oldRange.Address = "$M$3" Then
MsgBox "Do your stuff"
End If
End If
Set oldRange = Target
End Sub

Hoop that helps,


Wouter


Einar[_2_]

action on lostfocus in a cell
 
"Executor" skrev i en meddelelse
oups.com...
Hi to all

This is a step in correct direction.

Try this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static oldRange As Range
If Not oldRange Is Nothing Then
If oldRange.Address = "$M$3" Then
MsgBox "Do your stuff"
End If
End If
Set oldRange = Target
End Sub

Hoop that helps,


Wouter


Exatly what I needed - after I discovered that it not was in module, but
in
sheet (ark in danish) I should put it.

Tnx





All times are GMT +1. The time now is 02:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com