Change Positive Value in Range of cells to Negative Value based on the another cell Value

Mohamedazees

New Member
Joined
Oct 18, 2020
Messages
43
Office Version
  1. 2019
Platform
  1. Windows
Dear Sir,

I need the VBA to Convert the Positive numbers in rage of cells to Negative Number based on the another Cell Value ( Ref. attached Table)

1. The Conversion required Range are "Value" and "Tax" columns ( I.e. 4th & 5thColumn)
2. The Condition to be matched in column "Note" (I.e. 2nd Column) If the Note value is "Credit note" then the said range value to be converted to negative value

Trade/Legal Name
Note
Note number
Value
TaxDVSHOthers
UNITED CONSULTANCY SERVICES INDIA PRIVATE LIMITEDDebit noteCN/2020-21/060
102000​
18360​
0​
0​
0​
WORLDLINE INDIA PRIVATE LIMITEDDebit note5694029905
249294​
44872.92​
0​
0​
0​
WORLDLINE INDIA PRIVATE LIMITEDDebit note5694029906
219222​
39459.96​
0​
0​
0​
WORLDLINE INDIA PRIVATE LIMITEDCredit note5694029907
203612​
36650.16​
0​
0​
0​
WORLDLINE INDIA PRIVATE LIMITEDCredit note5694031042
11306​
2035.08​
0​
0​
0​
ICICI PRUDENTIAL LIFE INSURANCE COMPANY LIMITEDCredit noteGXL210100001584
1038.56​
186.94​
0​
0​
0​
IFFCO-TOKIO GENERAL INSURANCE COMPANY LTD.Credit noteH030839100009
3752.37​
675.43​
0​
0​
0​
IFFCO-TOKIO GENERAL INSURANCE COMPANY LTD.Credit noteH030839100011
2060.58​
370.9​
0​
0​
0​
IFFCO-TOKIO GENERAL INSURANCE COMPANY LTD.Credit noteH030839100012
4114.97​
740.69​
0​
0​
0​
IFFCO-TOKIO GENERAL INSURANCE COMPANY LTD.Credit note4771805100002
58704.88​
10566.88​
0​
0​
0​
IFFCO-TOKIO GENERAL INSURANCE COMPANY LTD.Credit note4424159700002
700.7​
126.13​
0​
0​
0​
Total
855806.06
154045.09
0.00
0.00
0.00
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try this with a copy of your workbook.

VBA Code:
Sub FlipCredits()
  With Range("D2:D" & Range("B" & Rows.Count).End(xlUp).Row)
    .Value = Evaluate("if(" & .Offset(, -2).Address & "=""Credit note"",-1,1)*" & .Address)
    .Offset(, 1).Value = Evaluate("if(" & .Offset(, -2).Address & "=""Credit note"",-1,1)*" & .Offset(, 1).Address)
  End With
End Sub

The totals will seem a bit odd though. Will they need adjusting to reflect the mix of positive and negative numbers above?
 
Upvote 0
Solution
You could probably do it manually in less time than it would take to run a macro.

Filter the data so that only the credit note rows are visible. Type -1 into an empty cell, then copy that cell and pastespecial > values and multiply to the visible value and tax cells.
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,822
Members
449,096
Latest member
Erald

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