check for negative and change the value in next column

GirishDhruva

Active Member
Joined
Mar 26, 2019
Messages
308
Hi every one ,

i am trying to search for negative value in column A and if negative value is found

then the value in next column(i.e, Column C ) should be checked and replaced if the value is 40 then to 50 or if the value is 50 then to 40 .

And even i need to change the negative value to positive and can we round off the decimal value .

Below is the sample workbook.

Regards,
Dhruva.
 
Here is a completely different way to write the macro...

Hi Rick, it is certainly another different way to write the macro, but it does not solve the user's requirement to round the number.
And even i need to change the negative value to positive and can we round off the decimal value .
In addition, your macro replaces the "-" in all sheets.

-----------------------------------------------------------------

Here my code compacted slightly:
VBA Code:
Sub check_negative()
  With Range("C1:C" & Range("C" & Rows.Count).End(xlUp).Row)
    .Value = Evaluate("=IF({1},IF(" & .Offset(, 4).Address & "<0,50," & .Address & "))")
    .Offset(, 4).Value = Evaluate("=IF({1},ABS(ROUND(" & .Offset(, 4).Address & ",0)))")
  End With
End Sub
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,215,950
Messages
6,127,906
Members
449,411
Latest member
AppellatePerson

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