Forum Discussion

yennifel's avatar
yennifel
Copper Contributor
Feb 05, 2023

Copying results in another cell

How can I have excel automatically copy the changes in a cell that has formulas into one that doesn't? For example, I have a formula on D18. Every time this value changes in D18 I want it to be updated in cell D4.

I would need this to be explained to me as if I were a child since I am no expert in Excel. Thank you

  • yennifel 

    The easiest way to do this, is to enter the formula

     

    =D18

     

    in cell D4.

    If you don't want a formula in D4 for some reason, you'll need VBA code.

    • Right-click the sheet tab.
    • Select 'View Code' from the context menu.
    • Copy the code listed below into the worksheet module.
    • Switch back to Excel.
    • Save the workbook as a macro-enabled workbook (*.xlsm).
    • Make sure that you allow macros when you open the workbook.
    • Warning: macros only work in the desktop version of Excel for Windows and Mac. They don't work in Excel Online (the version in the browser), nor on Android or Apple phones/tablets.

    Code:

    Private Sub Worksheet_Change(ByVal Target As Range)
        On Error GoTo ErrHandler
        If Not Intersect(Range("D18"), Target) Is Nothing Then
            Application.EnableEvents = False
            Range("D4").Value = Range("D18").Value
        End If
    ExitHandler:
        Application.EnableEvents = True
        Exit Sub
    ErrHandler:
        MsgBox Err.Description, vbExclamation
        Resume ExitHandler
    End Sub
    • yennifel's avatar
      yennifel
      Copper Contributor

      Hi, HansVogelaar 

       

      Thank you for your prompt response. I actually found a baby way to do it. I right-clicked on cell D18 (the one with the formula) and pasted it with the "paste link" option in cell D4 and the trick worked.  I did it with all the other cells I wanted and it was magic. 

      I appreciate this. Maybe I will need this in the future. 

       

Resources