You are here:

Excel/relating lost focus events


I am looking to make a simple VBA program which can relate one cell to another and then the visa versa depending on which cell the user intends to change so for example
Dim1=Dim2*2 and/or

the actual rate which affects the two cells is calculated using another piece of code and different data but i need these cells only to update the other cell once which ever one has been updated has been changed.

I have already tried to adapt a
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
type approach using help from this site,

However i am struggling to get this to operate on either of the cells at one time.

Many thanks in advance


It looks to me like you would PROBABLY be fine with the change event of the worksheet - as an example

Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox Target.Address
End Sub

would display a message box with the address of the changed cell.  So

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$1" Then
Application.EnableEvents = False
Range("C2").Value = 2
Application.EnableEvents = True
End If

End Sub

would then alter C2 to 2 IF C1 had been changed - as you can probably see, having two different IF cases would be no issue and setting the action taken should be relatively straightforward.

I hope that this gives you what you need - I found the question lost and lonely in the question pool where I assume it had gone after the person you originally choose to ask declined to answer it.
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Aidan Heritage


I have provided first hand support since `95 for Microsoft Office majoring in Word and Excel - support for all versions from 2 onwards. I'm based in the UK, so please allow for time differences when asking me questions from other parts of the world!


My background is in the insurance industry and call centre areas, but have been called upon to provide many varied solutions.

I'm educated to UK A level standard, but as I left school some 30 years ago that is rather irrelevent - university of life has provided more of a background!

©2017 All rights reserved.