Subtracting from a cell

MhmdHalawi

New Member
Joined
Aug 10, 2018
Messages
6
Hi all, I'm kinda new to Excel Vba, and I'm making a very small project, so the thing is , I have a column (C) that has a header and a bunch of values under it, and what I need is that each time I enter a value in that column it will be subtracted from a specific cell (F1), it should be done automatically after entering the value for example in C2 then F1 would be F1-C2 and if I enter a value in C3, then it would be subtracted from F1 again. So, F1-C2, F1-C3, F1-C4,... and so on.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi,

Go to VBA > double-click on Sheet1 > add this Event:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
    Application.EnableEvents = False
    
    With Sheet1
        If Target.Column = 3 Then
            Target.Value = Target.Value - .Range("F1").Value
        End If
    End With
    
    Application.EnableEvents = True
End Sub

Let me know if it works for you.

Best regards,
Justyna
 
Upvote 0
I want them reversed, your code subtracted them but put the value in C2, I want it to be F1-C2, and the value put in F1
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,834
Members
449,471
Latest member
lachbee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top