# VBA To Subtract Cells If Negative - Row Number Change With Loop

Apr 26, 2012

I have a database of over 200,000 parts

In this database i have cost and sale price. 20,000 parts have the numbers backwards.

if you loop the rows you can subtract =SUM(AE2-Y2) if that number is a negative number I would need the value of AE copied to Y2 and the value of Y2 copied to AE2. the 2 being the row number which would always change with the loop.

## If Negative Number - Change Cell Value To 0

Jan 3, 2012

I need formula for if cell value = negative number e.g.(-2202) change cell value to 0

## Change Textasnumber To Negative Number

Jun 2, 2008

My bank sends me my statement data as: Description, Date, Amount

...where the amount is text as a number followed by either a plus or minus.

Does anybody know how quickly convert the column of data into proper numbers?

I've been playing around with LEN, RIGHT and SEARCH, but not getting very far because I don't know how to extract the text to the left given the numbers vary in the number of digits...

## Number To Change Color For Positive & Negative

Dec 6, 2007

I am wanting to finish a worksheet for my boss. What I have done so far is taken the " forecast" of vehicles shown and used a formula of subtract from "actual" vehicles sold to get "how many we have left to go". what he wants to do is have the "to go" number change from red when a negative to green when it reaches a positive. example:

forecast = 30
actual = 27
to go = -3

that "to go" needs to be without a negative sign but in RED to negate a negative. Is that possible with a formula??

## Change Multiple Different Negative Numbers All Into One Specific Number?

Apr 5, 2014

How Do Change Multiple Different Negative Numbers All Into One Specific Number? Anither Words How do I change one number into another Number

Lets say I have list of numbers like this

-24
-19
-37
-22
-24
-42
-26
-20
-28
-23
-28
-42
-23
-53 etc.

and I want all the negative number at -21 and down to be changed into -20 and all other numbers higher then -20 or whole numbers to be left alone.

So numbers -21 -22 -23 -24 .... -36 -37 -38 .... -45 -46 etc are all changed into -20 and all other numbers like -19 -18 -17 -16 .... 0 1 2 3 4 etc are all left alone.

I tried using the filter tab and couldn't see. I tried the replace key but that took to long changing each and every number from -21 all the way back to -99.

Is there an easier way to change all negative numbers in a specific zone of numbers (-21 thru -99) into one simple number so -21 would change into -20 and -22 would change into -20 and -23 would change into -20 etc etc etc.

## How To Change Positive Into Negative Number Inside Cell Formula

Feb 7, 2014

How do I change a Positive number into a Negative number inside a cell formula?

I have a figure in Cell AE 101 which has the positive number 141

I have another cell W1 which has the positive number of 437

I want to create a formula in cell X1 that takes the number in cell AE 101 of 141 and convert the number inside the formula of 141 into a negative number of -141 and then subtracts that number from Cell W1 of 437 leaving an equation inside the formula to read. 437-141 = 296

Since the number in Cell W1 changes all the time and the number in AE101 Changes all the time the new formulated number in X1 will change all the time too as the cells get updated.

## Subtract Positive And Negative Numbers

Sep 14, 2009

IF formula.

I am trying to subtract 2 numbers, and they are 4 different combinations of positive and negative numbers.

I wrote the formula as
=IF(A5*B5>0,IF(AND(A5*B54,458 2,367 (322)FALSE(1,277)1,751 FALSE

## Date / Time - Subtract Number Of Days Between Cells Only

May 2, 2014

I have a cells with a date and time in each cell. I want to subtract the number of days between the cells only. Is there a way to do that with the time in the cell? If not, how do I remove the time in each cell?

## Subtract Negative Numbers Within Pivot Table Data Field

Jul 6, 2009

Ive attached a spreadsheet showing what im trying to achieve. basically i have a scheduling objective, in which only a few slots (AA, BB, CC) are available. so the starting availability is fixed. for this example assume the starting values are 6,7, and 8 respectively. as 'bookings' are entered, im using the value of -1 against A, B, or C respectively, to indicate that AA, BB, or CC should be decreased by 1 unit of availability.

im trying to incorporate the subtraction within a pivot table. as you can see i am way off. the hypothetical formula logic that im trying to implement within the PivotTable would look something like this:

for A,B or C, sum all (-1) values for each instance of Date and Stage... this will give total bookings

add this total value to the starting values of AA, BB, CC respectively to get the new availability

## Negative Number In Cells Collection

Aug 2, 2007

I came across this expression going through an Excel VBA code. Can someone plz explain what the argument (-1,1) points to ?

## Reference Cell & Add Amount If Positive & Subtract Amount If Negative

Jun 5, 2008

Im trying to set up an active running inventory sheet where: (A)the progressive daily sheet cells reference back to the corresponding master sheet cells fluctuating the master values, (B) the same progressive daily sheet cells reference back to a cummulative totals-cell based on whether I added or subtracted inventory. I want to make a copy of the blank "sheet 2" with all of the formulas and move it to the end of the workbook each day and enter new values which will reference back to the master sheet so that I can click on a date sheet and see an individual day's values or click on the master sheet to see the fluctuating inventory on-hand and the cummulative +/- totals of all days combined. I've got a couple hundred individual cells to reference. I've tried and tried but I can't make it work. Heres what I need to do:

I need to reference individual cells from "sheet 2,3,etc" back to a corresponding cell in a master sheet. But I need the values in each cell in "sheet 2,3,ETC" to increase or decrease the corresponding cell values in the master sheet. For example: If the value in the master sheet B5 is 200. Then in sheet 2, I enter +50 in B5, I need the master sheet cell B5 to increase by 50 to 250. I also need a way to decrease the cell value in the master sheet B5 if I enter a negative value -50 in sheet 2 B5. I also want to know if I can reference the same cell values entered in "sheet 2,3,etc cell B5" back to totals columns C5 for adding inventory or D5 for subtracting inventory in the master sheet where the master totals columns would reflect cummulative totals added or subtracted. For example: if the value in sheet 2 B5 is +50, then the value in Master sheet C5 would add 50 to a progressive total. But if the value in sheet 2 B5 is -50 then the value in master sheet D5 would add -50 to a progressive total.

## With Loop + Find Method And Sum The Negative Values

Feb 23, 2010

I have a very large worksheet (row count maxed in 2007, and then some), for which I need to do the following: search column A for a string that will occur many times, and then check the 10 cells that follow in its row for negative values, dropping some sort of indicator in the 11th (shading it red or something would be fine). An additional bonus would be if the 10 cells that possibly contain a negative could be summed (the sum could serve as the indicator?). If no negative is found, nothing need be done, and the macro should chug along searching A for the next reference to this string.

My hope was to do a sort of "With Range("A:A"), .Find("MyString")", save position as StartPos, do the 10-cell row checking in a nested IF or For (though the For would take a long while, checking each cell individually), then doing a .FindNext after StartPos until = StartPos (does .FindNext loop back to the top?). The formatting of the indicator cell in the 12th cell in each relevant row doesn't really matter, it's more just for jumping to critical rows.

## Formula To Subtract A Number Per Day

Aug 5, 2009

I needa formular that will subtract a number per day, for example as one day passes you can set the amount of number to be taken away from the total.

## Carrying Over Negative Number To Next Column As Positive Number?

Aug 21, 2014

I go negative in one column I want it to show up in the next column as a positive number because when I add my income and subtract my bills and the negative from last month to get the what cash I'll have left it screws up because negative subtract a negative is a positive. So how do i get the sum of say B9 to from -\$5.00 to +\$5.00 into C4 so when i subtract C4 From my income it wont add to it.

## Excel 2013 :: Formula To Subtract 7th Column Values From Column Before 1st Loop?

Feb 21, 2014

I have a code that inserts a new column after every 7th column. I want to include a formula where every 7th column value is subtracted from the values present in the column before the 1st, or you can think of it as subtracting 7th column of the present group from the 7th column of the previous group. Example: The range of my data starts from col F, then

F (7th) New Column (G) H (1st) I (2nd) J (3rd) K (4th) L (5th) M (6th) N (7th) New Column (O) P (1st) Q (2nd) R (3rd)

So, New Column (O) = N - F
and the next New Column (W) = V-N ...

NOTE: Column G can be ignored.

I want to add a looping function to this so that it will continue to subtract for the other respective columns as well. How do I incorporate this into the following code?

[Code].....

I'm using Excel 2013.

## IF Condition Of Gender AND Age Met Subtract Number

Jan 15, 2014

I am attaching my spread sheet.

I need to create a function for cell E9 that will look at cell D4(gender) AND cell C5 (age in days) and choose the correct value J3:M3 (boys) or O3:R3 (girls) to subtract form cell C9.

I tried =IF(D4=2(AND(C5<E3,sum(C9,-5),FALSE)) but did not get anywhere.

CI formula.xlsx

## Subtract Number Of Workdays From A Date

Feb 26, 2014

I am looking for a formula which substract a number of workdays defined in a cell from a date defined i nanother cell. For example I have a date in cell B2: 10.08.2014 - this is the due date for service delivery. In cell C2 there is a number of workdays: 84 - this is the duration for the delivery process. I would like to have a formula calculating in cell D2 the date when the delivery process has to start. The tricky point is that B2 is basicly a range of merged cells B2:B6. As an example I am attaching an exmple sheet.

## Running Total VBA - Add / Subtract Number In B And C?

Apr 10, 2014

I am creating a spreadsheet for inventory use. I want to have a running total in (1) cell based upon a new/different number being entered into a different cell.

Column B, Row 1 (This will be a new/different number entered every day - inventory in or out, so positive or negative number)

Column D, Row 1 (This will be a running total based on numbers inserted in previous 2 columns)

Basically what I have is a key inventory. So there is column A with key number, B should be keys IN, C should be keys OUT, or ideally B would be IN and OUT meaning, for inventory IN input a positive number and for inventory OUT input a negative number, and D Should be total.

Column E represents number of keys currently in the inventory. I was going to hide the current inventory column so all you see is IN/OUT and total. So what I need is to be able to just come in and type in a number in the IN and/or OUT column, without having to add/subtract it with the number already in that column.

Bottom line, I'd like to be able to use IN and/or OUT columns to just type in numbers as they come and not have to worry about what's already in those columns and get correct total number.

Ok here it is. Attached worksheet shows
Column A - Key Numbers...No data value
Column B - Inventory IN
Column C - Inventory OUT
Column D - Total
Column E - Current Inventory(Starting point)

So the formula I used to get what i currently have is (=B2-C2+E2). This way whatever i input in columns C and C. totals out in D. But this way every time I want to add/subtract a number in B and C, i have to add to the number already in the column. I'd like to be able to type in a number in B and C as i go and still have a correct total. I wouldn't mind having just one column for in/out and use positive and negative numbers to differentiate inventory in or out.

## Subtract The Lower Number From The Highest

Aug 12, 2006

I have name and a number in this

format: cell a1 Jones---56. In cell b1 I have another name i.e.,
Johnson---45. How can I subtract 45 from 56, take 60% of the difference
and in cell c3 show the following; Johnson---6. All numbers are to
rounded down to 0. The final result would look like this;
a1 Jones----56, b1 Johnson----45, c1 Johnson----6. I have other cells
with the same type of info in them. Example; a2 Smith----34, b2
Jones----78, c3 would show Smith----26.(rounded down) I always want to
subtract the lower number from the highest and take 60% of the
difference.

## Using Drop Down Box To Subtract From Number Based On Yes Or No?

Dec 2, 2011

I created a drop down box with 3 options. Yes, No, and N/A. I want to subtract from a fixed number (8) a certain amount based on the answer. Something like if yes then subtract 1 from 8 and have the final number (7) appear in another cell.

screenshot attached.

[URL]

## Subtract A Number From Range Of Values

Dec 11, 2013

I have a column which contains following values:

Code:

646-900
634-645
611-633
589-610

and so on

I want to first reverse the range in each row and then subtract the values from 2000 so that it now becomes

Code:

1100-1354
1355-1366
1367-1389
1390-1411

How can I write the formula?

## Subtract Number From Column Of Numbers

Oct 4, 2006

I have data on A1 to A100. How can I subtract a same number (for example 10)from each cell of A1:A100?

## X= Formula; Subtract The Number From Cell C32

Mar 19, 2007

in Cell J32 I want it so when i type in a number it would subtract the number from Cell C32. Is there a formula in which all you have to do is type the number without editing the formula?

## Subtract From Number On Right Of Alphanumeric Text

Oct 15, 2007

We use excel to organize salaries and contracts for my fantasy baseball league. I need an easy way to go through all the teams and subtract one year from each players contract. This is an example of a team.

The contracts are in the columns like this NG-3

I would like to change that to NG-2

## Formlula: Subtract Largest Number Then Average

Oct 10, 2009

I am trying to subtract the highest number from a row of numbers then find the average for the remaining numbers in Excel 2003, as: =SUM(B2:E2)-MAX(B2:E2)AVERAGE(B2:E2).

## Subtract Column Values With Lowest Number Among Them?

May 22, 2013

I have an excel with column value as below(sample)

3
4
6
7
empty cell
4
5
3
1
7
empty cell
4
5
empty cell
and more...

Actually i want it to reduce others with lowest number among them.. and after every empty cell, it should find the lowest number again and reduce it from others.. this should repeat until the column data completes. after processing it should find as below

0
1
3
4
empty cell
3
4
2
0
6
empty cell
0
1
empty cell

Any macro or excel formula for processing such a kind of excel. Empty cell works like a delimiter..

## Subtract Decimal Number From Current Date

Nov 14, 2006

Need to find out exact date. if I insert 32.5 (32 years 5 months ) in particular cell. my output shld be 10 june 1974 or 10/06/1974. I want to find back date...

## Formula To Change A Negative No To A Positive

Dec 26, 2006

This may be more of a math question rather than an Excel one.

If I have a spreadsheet with a cell that produces different negative number each time it is used, is there a way i can add a formula to make it a positive number.

So if Cell A1 showed -£244.22, I want to add an equation that changes if to £244.22

Cell A1 changes so it would need to do the same for any negative number within that cell.

## Change Negative Output Of IF Statement?

Nov 21, 2013

I have created the If statement below, in a nutshell its comparing current month performance to last month, stating if it has increased or decreased by last month and how much percentage by

example output would be 'This has decreased by x%"

my problem is when it states the performance has increased , the x% is coming as a negative number (-x%)

what can I do to change this to positive?

Below is the formula

=IF(INDEX('Red Activity & Performance'!\$E\$45:\$J\$45,MATCH(PERFORMANCE!\$AK\$31,'Red Activity & Performance'!\$E\$44:\$J\$44,0))

## Store Row Number Within Loop And Delete All Stored Rows After Loop?

Sep 11, 2013

I have working code that returns a row number within a for loop based on parameters I set.

Each time the for loop runs I would like to store this row number, then after the loop has finished, delete all stored rows.

Code:
for rowNum = 1 to x (some variable end row number which I already have worked out using End(xlUp).Row)
if x = y then
*storedRow = rowNum
end if
next rowNum
*

Lines with a * are the bits I can't work out. I've been trying to understand arrays by reading posts on what other people have done, but I can't fit (or fully understand) the reDims, or reDim preserves into my code. I've seen what appear to be quite complex ways involving uBounds and LBounds, but unfortunately I can't see how to use them.

All I want is to simply keep adding a row numbers to a variable, (i.e. row 2, 5, 20, 33, 120, etc) and then delete those specific rows.