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 :(
 
You could assign a macro to the combo box that just sets the numberformat of the cell(s) to either "0" or "0%" depending on selection but it would seem easier to just type 1 or 2 manually to me.
 
Upvote 0

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You could assign a macro to the combo box that just sets the numberformat of the cell(s) to either "0" or "0%" depending on selection but it would seem easier to just type 1 or 2 manually to me.

thanks and I was the final user of the sheet I just would do that unfortunately it will be quite a few that use it and I was really hoping to avoid them typing.


thanks once more for all your help!!!!
 
Upvote 0
Basic macro would be:
Code:
Sub DropDown1_Change()
   Dim strFormat As String
   If ActiveSheet.DropDowns(Application.Caller).Value = 1 Then
      strFormat = "0"
   Else
      strFormat = "0.0%"
   End If
   Range("A1:A10").NumberFormat = strFormat
End Sub

BTW, please read the forum rules on cross-posting (they are much the same in almost all internet forums) and provide links to your cross-posts in future. Thanks.
 
Upvote 0

Forum statistics

Threads
1,216,084
Messages
6,128,724
Members
449,465
Latest member
TAKLAM

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