Change formatting of cells with IF

officehelp

New Member
Joined
Dec 6, 2010
Messages
10
Is there a way to change the formatting of numerous cells if one cell is a certian number?

Example
A4:U4 would change if M4 had an amount of 1, it would change to a different format is it was 2 and 3 and 4.

Thank you,
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Perhaps using code. Right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "M4" Then
    Select Case Target.Value
        Case 1: Range("A4:U4").NumberFormat = "0.0"
        Case 2: Range("A4:U4").NumberFormat = "0.00"
        Case 3: Range("A4:U4").NumberFormat = "0.000"
        Case 4: Range("A4:U4").NumberFormat = "0.0000"
    End Select
End If
End Sub

Press ALT + Q then try changing the value of M4.
 
Upvote 0
Highlight A4:M4, go into conditional formatting.
New Rule, Use a formula to determine which cells to format.
Enter: =$M4=1 and then choose the format.
Repeat with new rules for 2, 3, 4, etc.

Copy to whatever rows as needed.
 
Upvote 0
Highlight A4:M4, go into conditional formatting.
New Rule, Use a formula to determine which cells to format.
Enter: =$M4=1 and then choose the format.
Repeat with new rules for 2, 3, 4, etc.

Copy to whatever rows as needed.

okay so this worked but how do I copy it. I am an idiot when it comes to Excel and am getting very aggrevated. But again thank you for your help :)
I have over 100 rows that need this formula
 
Last edited:
Upvote 0
Highlight A4 to U4, right-click, select Copy. Highlight the range which you want to copy, right click, Paste Special, Formats.

Also, above I wrote that you should highlight A4:M4 before doing all the conditional format stuff... that should've been A4:U4. My apologies.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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