Change cells number format off an other cells value

MDuff

Well-known Member
Joined
Dec 29, 2002
Messages
529
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am using an if statement that depending on the value in B1 is a 1 or a 2 will ether return a number or a Percentage. I am trying to get excel to change the format if the value in b2 is 1 to a % format and if it is 2 to a number format.

I have tried using these two rules in conditional formatting but it is not working and getting "stuck" in one of the formats

=$B$1=2 format as Number
=$B$1=1 Format as Percentage


Here is an example that should be formatted as a percentage

Excel 2007
ABCD
11% Used
2Net Seats
328-Oct-134-Nov-13
4Seat Utilization% for Actual Prod Staff11
Summray
Cell Formulas
RangeFormula
C3=Springfield!B8
C4=IF($B$1=1,VLOOKUP(C$3,Greeley!$B$8:$BI$33,58,FALSE),VLOOKUP(C$3,Greeley!$B$8:$BI$33,12,FALSE)-(VLOOKUP(C$3,Greeley!$B$8:$BI$33,9,FALSE)))
D3=C3+7
D4=IF($B$1=1,VLOOKUP(D$3,Greeley!$B$8:$BI$33,58,FALSE),VLOOKUP(D$3,Greeley!$B$8:$BI$33,12,FALSE)-(VLOOKUP(D$3,Greeley!$B$8:$BI$33,9,FALSE)))


Here is an example as a number


Excel 2007
ABCD
12% Used
2Net Seats
328-Oct-134-Nov-13
4Seat Utilization% for Actual Prod Staff9196
Summray
Cell Formulas
RangeFormula
C3=Springfield!B8
C4=IF($B$1=1,VLOOKUP(C$3,Greeley!$B$8:$BI$33,58,FALSE),VLOOKUP(C$3,Greeley!$B$8:$BI$33,12,FALSE)-(VLOOKUP(C$3,Greeley!$B$8:$BI$33,9,FALSE)))
D3=C3+7
D4=IF($B$1=1,VLOOKUP(D$3,Greeley!$B$8:$BI$33,58,FALSE),VLOOKUP(D$3,Greeley!$B$8:$BI$33,12,FALSE)-(VLOOKUP(D$3,Greeley!$B$8:$BI$33,9,FALSE)))



Any Ideas I am willing to use VBA I was thinking of a change event but I could not figure out how to get the code to work :(
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Strange, it works just fine for me using your same formulas in conditional formatting.

Cell B1 = 2:


Excel 2010
ABCD
12% Used
2Net Seats
328-Oct-134-Nov-13
4Seat Utilization% for Actual Prod Staff1.001.00
Conditional Conditional Formatt


Cell B1 = 1:


Excel 2010
ABCD
11% Used
2Net Seats
328-Oct-134-Nov-13
4Seat Utilization% for Actual Prod Staff100.00%100.00%
Conditional Conditional Formatt


My conditional formatting rules are:

Rule 1:
1) Applies to: =$C$4:$D$4
2) Use formula: =$B$1=2
3) Format --> Number --> Number

Rule 2:
1) Applies to: =$C$4:$D$4
2) Use formula: =$B$1=1
3) Format --> Number --> Percentage
 
Upvote 0
Not sure that the same logic i used on thing to note I noticed is I am in Excel 2007 and your on 2010 not sure if that makes a difference
 
Upvote 0
Not sure that the same logic i used on thing to note I noticed is I am in Excel 2007 and your on 2010 not sure if that makes a difference

You don't know if it's the same logic used? I don't really understand that sentence, but if you didn't use those formulas before, do you want to try it and post the result here? It is working on my version of your spreadsheet.

And I don't believe the version should make a difference. This should work the same on 2007.
 
Upvote 0
Ok I tested this set up on a new worksheet and it works so now I am not sure why it will not work on the book I originally Posted


I have:

Rule 1:
1) Applies to: =$C$4:$D$4
2) Use formula: =$B$1=2
3) Format --> Number --> Number


Rule 2:
1) Applies to: =$C$4:$D$4
2) Use formula: =$B$1=1
3) Format --> Number --> Percentage

No Stop if true Selected

and this is what I get if 1 or 2 is selected...on the workbook originally posted


Excel 2007
ABCD
11% Used
2Net Seats
328-Oct-134-Nov-13
4Seat Utilization% for Actual Prod Staff11
Summray
Cell Formulas
RangeFormula
C3=Springfield!B8
C4=IF($B$1=1,VLOOKUP(C$3,Greeley!$B$8:$BI$33,58,FALSE),VLOOKUP(C$3,Greeley!$B$8:$BI$33,12,FALSE)-(VLOOKUP(C$3,Greeley!$B$8:$BI$33,9,FALSE)))
D3=C3+7
D4=IF($B$1=1,VLOOKUP(D$3,Greeley!$B$8:$BI$33,58,FALSE),VLOOKUP(D$3,Greeley!$B$8:$BI$33,12,FALSE)-(VLOOKUP(D$3,Greeley!$B$8:$BI$33,9,FALSE)))


this is on the new workbook that works


Excel 2007
ABCDEF
12% Used
2Net Seats
328-Oct-134-Nov-13
4Seat Utilization% for Actual Prod Staff3001
5
6
7
8
910.3
102300
Sheet1
Cell Formulas
RangeFormula
C4=VLOOKUP(B1,$E$9:$F$10,2,FALSE)


Any Ideas why it works in one sheet and not an other?
 
Upvote 0
Do you have any other rule on the first worksheet that might be overriding the new rules?
 
Upvote 0
I think I found something out and I am sorry i left it it out I am using a Combo Box to Populate the 1 and 2 in B2 If I use the Combo Box it will not change the format BUT if I manly Type the number if and hit enter it will change it so I am thinking it must be something with Combo Box and excel not "refreshing" to trigger the conditional formatting.

I hope this additional information helps and any ideas on how I can still use the Combo Box and the Conditional Formatting?

thanks
 
Upvote 0
Right click on the Combo Box, and hit Format Control. Copy/paste to this forum what is in the input box for Cell Link.
 
Upvote 0
Is the value in B1 manually entered, the result of a formula or selected from a data validation list? I seem to recall that Excel 2007 was buggy in this regard, especially if using a DV list.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,716
Members
448,985
Latest member
chocbudda

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