formula help

ron0816

New Member
Joined
Feb 20, 2019
Messages
7
I need so assistance with a formula. I am trying to use and if statement to determine a amount. I have a column that has a value of 1,2,or 3. If the value is 3 I need to take the amount in another column and multiply it by -1. Also if the value is 1 but the amount is already a negative amount I need to multiply it by -1. Any help you can give me is appreciated. Thanks
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Try

Code:
Sub FixCol()
Dim LR As Long
Dim i As Integer
LR = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To LR
  If Cells(i, 1) = 1 And Cells(i, 2) < 0 Then
  Cells(i, 2) = Cells(i, 2) * -1
  ElseIf Cells(i, 1) = 3 Then
  Cells(i, 2) = Cells(i, 2) * -1
  Else
  End If
Next i
End Sub

Might be possible without a loop, but haven't given it enough thougth.
 
Upvote 0
Could you put this into a If,And statement. if column g has the values of 1,2, or 3 and column j has the amounts.
 
Upvote 0
Then, where do you want the changes?

Code:
=IF(G1=3,-J1,IF(AND(G1=1,J1<0),-J1,J1))
 
Last edited:
Upvote 0
You need something like this

<table border="1" cellspacing="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:76.04px;" /><col style="width:76.04px;" /><col style="width:76.04px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="text-align:right; ">1</td><td style="text-align:right; ">FALSO</td><td style="text-align:right; ">6</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td style="text-align:right; ">2</td><td style="text-align:right; ">FALSO</td><td style="text-align:right; ">4</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td style="text-align:right; ">3</td><td style="text-align:right; ">-8</td><td style="text-align:right; ">8</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td style="text-align:right; ">1</td><td style="text-align:right; ">5</td><td style="text-align:right; ">-5</td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b>Formeln der Tabelle</b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Zelle</td><td >Formel</td></tr><tr><td >B2</td><td >=IF(A2=3,C2*-1,IF(A2=1,IF(C2<0,C2*-1)))</td></tr></table></td></tr></table>

If it's something different, you could give examples.
 
Upvote 0

Forum statistics

Threads
1,223,882
Messages
6,175,165
Members
452,615
Latest member
bogeys2birdies

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