# Display Calculation with Values in the Calculated Cell

Hi,

I have two columns A & B with numbers in it. I have to deduct the number in Column A with the number from Column B. The deduction is to be done in Column A.I want column A to display the calculation with the amounts from the respective cells. For e.g If Column A1 has 100 and B1 50, then A1 cell should show the formula” =100-50″.

I have to do this calculation in a specific range only (e.g A10 to A20).

Is it possible?

Thanks

Top Contributor Asked on January 3, 2017 in

Thanks……..

Top Contributor Answered on January 6, 2017.

Hi, The below macro will check each cell in the selection, and prints the calculation if the cell is in Column A.

```Sub SubtractValues()
Dim myVal As Range
For Each c In Selection
If c.Column = 1 Then ' check if the column is 1 (i.e A)
c.Formula = "=" & c.Value & "-" & c.Offset(0, 1).Value
End If
Next
End Sub
```

Thanks!

Expert Answered on January 5, 2017.

Hi,

Its not possible as per my knowledge. You should have data in cell (B1) and cell (C1) . Now you can subtract value at cell A1 like(=B1-C1).

Here is the screen shot for your reference.

Thanks

Expert Answered on January 3, 2017.

Thanks Valli…..

Well, I thought as the question was framed under “VBA” I don’t have to mention it and that made the difference.

Please find the screen shot.

What I wanted to know is , can we edit the macro in such a way that it picks up the value from column B and subtracts it from the value in column A. The formula bar should show the calculation with the values in column A and B displayed. The cell will show the result.

Top Contributor Answered on January 5, 2017.
• ## Found this useful?

Please share using the share button above.

If you found the answer is best answer for your question, Please mark as 'best answer' by clicking on the right tick mark icon at the left side of the answer.

Found the answer useful and wants to credit the user, then vote the answer (vote up).