Conditional formatting or vba ?

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,731
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I have a CF of which the code is =$B1="REFUND" & it triggers the text on that row in question to be RED.

I would like please if REFUND is seen in Column B on the sheet then any value entered in Column D will be changed to Negative value.

Would this be an edit to the working CF at present or a simple separate VBA code ?

Please advise thanks.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
what should happen if someone removes 'REFUND'?

And must it turn negative, or must the number be negated? I..e. -1 will turn to 1?

And is D formula generated?
 
Upvote 0
If REFUND is moved it will be by the row delete option.

If REFUND is shown in column B then in column D of the same row £54.99 is entered it should change itself to -£54.99

Only format for column D is the row D29:D30 so this new code would only apply to the range D5:D28

Thanks
 
Upvote 0
Hi

You cannot actually change the value with COnditional Formatting but you can format it to display a negative format (even though it will remain positive).

For VBA, right-click the sheet tab -> View Code and paste this in to the code pane:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Application.Intersect(Target, Me.Range("B5:B28")) Is Nothing Then
        On Error Resume Next
            If Target.Value = "REFUND" Then Target.Offset(, 2).Value = -Abs(Target.Offset(, 2).Value)
        On Error GoTo 0
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,179
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