-1

I have a spreadsheet I am trying to setup some code so when a user changes field E13 a reminder comes up highlighting fields E19, E29, E31, E39, E41. E13 is a change order field with a money value and I want users to know they need to address the other fields once they change E13. I want the cells to be highlighted if possible.

LS_ᴅᴇᴠ
  • 10,823
  • 1
  • 23
  • 46

1 Answers1

2

Install the following event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim E13 As Range, rFix As Range
    Set E13 = Range("E13")
    Set rFix = Range("E19,E29,E31,E39,E41")
    If Intersect(E13, Target) Is Nothing Then Exit Sub
    Application.EnableEvents = False
        rFix.Interior.ColorIndex = 6
        MsgBox "Please update the hi-lighted cells and remove the hi-lighting"
    Application.EnableEvents = True
End Sub

Because it is worksheet code, it is very easy to install and automatic to use:

  1. right-click the tab name near the bottom of the Excel window
  2. select View Code - this brings up a VBE window
  3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it. If you are using a version of Excel later then 2003, you must save the file as .xlsm rather than .xlsx

To remove the macro:

  1. bring up the VBE windows as above
  2. clear the code out
  3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

and

http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

Macros must be enabled for this to work!

Gary's Student
  • 95,722
  • 10
  • 59
  • 99
  • 1
    + 1 :) You might also wanna see [this](http://stackoverflow.com/questions/13860894/ms-excel-crashes-when-vba-code-runs/13861640#13861640)... the 3rd point... since you are using worksheet_change – Siddharth Rout Sep 20 '13 at 13:17