Add to one column, subtract to another.

BradMcLeod

New Member
Joined
Jun 8, 2015
Messages
40
I feel this may have to be a macro, because of the scale and the way I'm using it.
I want J3 and higher (J4, J5 etc) to subtract 1 from itself everytime G3 and higher change. In the same line.
If G4 changes, then J4 subtracts 1 from itself
If G5 changes, then J5 subtracts 1 from itself.

Column G will only ever go up. As it is ALREADY in a formula of auto sum of B, C and D. This will have to be a macro, I believe, because the starting number for J will be fluid, and have to be input and periodically changed, manually.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Column G will only ever go up. As it is ALREADY in a formula of auto sum of B, C and D.
Is column G just summing up the values of B, C, and D in the same row?
Are the values in B, C, and D manually entered?
 
Upvote 0
Right-click on the sheet tab name at the bottom of the screen, select View Code, and paste this code in the VB Editor window that pops up.
This should do what you want automatically, anytime a a value is updated in columns B, C, or D, starting on row 3, the value in column J of that row will be decreased by one.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rng1 As Range
    Dim rng2 As Range
    Dim cell As Range
    
'   Set range to watch for changes
    Set rng1 = Range("B3:D" & Rows.Count)
    
'   See if any watched cells change
    Set rng2 = Intersect(rng1, Target)
    
'   Exit if no cells in watched range updated
    If rng2 Is Nothing Then Exit Sub
    
'   Loop through changed cells in watched ranges
    For Each cell In rng2
'       Remove one from column J in that row
        Cells(cell.Row, "J") = Cells(cell.Row, "J") - 1
    Next cell

End Sub
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,044
Members
448,543
Latest member
MartinLarkin

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