conditional formatting

tnoe

Board Regular
Joined
Jul 14, 2002
Messages
76
When using conditional formatting for a cell, How do you or can you do =
this?

Choose greater than or equal to zero. then divide by 2

example....

I type in a cell 1000 and how can I automatically get it to be divided =
in half?

Thank You
Tracey Noe
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
You can't do that with conditional formatting, it only affects the appearance of a cell dependent on your specified condition, not its value. You can do this with a Change event in VBA- if you're interested repost with exact details of what you want to happen and which cell or range of cells will be used.
 
Upvote 0
I have been working on coding to do that. If you place this macro in the Sheet module in the VB editor (Sheet1, or whatever sheet you are working on), it will happen automatcially whenever anything is entered into the cells.

I wrote it to work on column G. Modify to suit your needs.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Application.EnableEvents = False
    
'   This does column G (the seventh column)
    If Target.Column = 7 Then
        If Target.Value < 0 Then
            MsgBox "Cannot enter a value less than zero"
            Application.Undo
        Else
            Target.Value = Round(Target.Value / 2, 1)
        End If
    End If
        
    Application.EnableEvents = True

End Sub
 
Upvote 0
Ok, I am not that familiar with macros. Is there an IF formula that could make this work?

Tracey
 
Upvote 0
This is the only way you can control the data as it is entered.

If they enter the value in column A1, you could do conditional formatting to ensure that it is not less than zero. However, you can not have the entry be divided by two as it is entered without the use of a macro. In B1, you could enter = A1/2, which would divide it by 2, but you still would have the original amount in A1.
 
Upvote 0
I can put the formula in the cell 1b where it would change 1a.

I want it to say: If 1a has value then make it divisible by 2. I just do not know how to word that for the formula to work.

Tracey
 
Upvote 0
I don't think that worked. Thank you for your help. I will just have to do something else.

Tracey
 
Upvote 0
As Mudface and I said earlier, you cannot change the value of what is being entered into a cell without the use of a macro. The formula that I gave you, if entered into cell B1, just looks at what is entered into cell A1 and does the math on it if the value is greater than 0. It will not change what is in A1.

If you want to divide a whole column by 2, and overwrite the original values, you can do that using Copy | Paste Special | Divide.
 
Upvote 0

Forum statistics

Threads
1,221,709
Messages
6,161,431
Members
451,705
Latest member
Priti_190

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