create negative value in one cell based on value in another

rickf19

Board Regular
Joined
Aug 30, 2019
Messages
66
Office Version
  1. 2016
Platform
  1. Windows
Hi

I have a list of headings in col A however in col I all the amounts are positive I need to change the value in col I to a negative if the heading in col A is Fees, there are 40 or so different headings over hundreds of rows I have filtered col a to show only Fees but cant change the positive to negative in col I without affecting all the other headings once I take the filter off

Any ideas gratefully accepted

Rick
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try this:
VBA Code:
Sub NegateFees()

    Dim r As Long
    Dim lr As Long
    
    Application.ScreenUpdating = False
    
'   Find last row in column I with data
    lr = Cells(Rows.Count, "I").End(xlUp).Row
    
'   Loop through all rows of data
    For r = 1 To lr
'       See if column A equals "Fees"
        If Cells(r, "A") = "Fees" Then
'           Negate value in column I
            Cells(r, "I").Value = 0 - Cells(r, "I").Value
        End If
    Next r
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Solution
Hi Joe
Took me a while but managed to create the macro and run it, seems to have done the trick.

Many thanks
Rick
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,214,795
Messages
6,121,624
Members
449,041
Latest member
Postman24

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