QUESTION: Hello Bob, I would like to have a macro that would automatically change the info in cells whenever I change the source cells. Ex: I have info in cell b15 (but b15 has a formula using the IF statement to display info from 2 other cells, d6 and d7.)I would like to copy the results in b15 and special paste the results as "values only" to another cell, say b20.
Anytime I change d6 or d7, the macro would automatically run.
Please help.

ANSWER: Right-click the sheet tab, select View Code, enter this:

Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Address = "$D$6" or Target.Address = "$D$7" then
      Range("B20").Value = Range("B15").Value
  end If
End Sub

---------- FOLLOW-UP ----------

QUESTION: Hello Bob, I was hoping the solution could be handled by the "Record a Macro" and after all steps are done, click the "Stop Recording" button.
Can you show me.

ANSWER: You can't record macros that should run when something "happens", like when D6 or D7 changes, then do something. You can record the copy B15 and paste values into B20, but nothing will make that happen automatically. This is an event-driven macro, and those simply can't be recorded.

---------- FOLLOW-UP ----------

QUESTION: Hello Bob, I coded it just like you stated and it works. I would like to add to this coding to automatically copy and special paste the "values" only because the following cells have formulas).
B74 to B51
B75 to B52
B76 to B53
B77 to B54
B78 to B55

I know I am asking a lot, but this what make my day.

Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Address = "$D$6" or Target.Address = "$D$7" then
      Range("B20").Value = Range("B15").Value
      Range("B51").PasteSpecial xlpastevalues
  end If
End Sub

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


Bob Umlas


I`m a Microsoft Excel MVP (Most Valuable Professional) and have been since the inception of the program in 1995. I can answer every kind of Excel question except: API, Importing/exporting to other programs (powerpoint, word,...) Also check out my in-person training link at http://www.thumbtack.com/ny/new-york/excel-training/


Worked with MS Excel since version 0.99 (on the Mac!). Was contributing editor to Excellence Magazine, having written >300 articles. John Walkenbach said of me "I finally met someone who knows as much about Excel as I do."

Excellence, The Expert, Microsoft

BA in math, Hofstra University, 1965

Awards and Honors
Led sessions for the Convergence 2004-2006 seminar on Excel tips & tricks

©2017 About.com. All rights reserved.