Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Conditional formating of cells

Good afternoon,

I have an array of numbers in excel. I want then to display as percentage
if I've selected "proportional" from a drop down menu. I want them to
display as a number (0.00 for example) if I select "absolute" these are the
only two options in the menu.

I'ved tried using the Format code help in Excel but I can't manuipulat it to
get it to work how I want.

Any help will be greatly apprecaited.

Thank you!

Michelle
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Conditional formating of cells

Let's put the drop down in column A and the data to be formatted in column B.
Enter the following in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim A1 As Range, B As Range
Set A1 = Range("A1")
Set B = Range("B:B")
If Intersect(Target, A1) Is Nothing Then Exit Sub
Application.EnableEvents = False
If A1.Value = "proportional" Then
B.NumberFormat = "0.00%"
Else
B.NumberFormat = "General"
End If
Application.EnableEvents = True
End Sub


Because it is worksheet code, it is very easy to install and automatic to use:

1. right-click the tab name near the bottom of the Excel window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu201002


"michelle439731" wrote:

Good afternoon,

I have an array of numbers in excel. I want then to display as percentage
if I've selected "proportional" from a drop down menu. I want them to
display as a number (0.00 for example) if I select "absolute" these are the
only two options in the menu.

I'ved tried using the Format code help in Excel but I can't manuipulat it to
get it to work how I want.

Any help will be greatly apprecaited.

Thank you!

Michelle

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Conditional formating of cells

Awesome, thank you very much, that works perfectly.

And thanks for the links, I'll check them out.

Cheers,

Michelle

"Gary''s Student" wrote:

Let's put the drop down in column A and the data to be formatted in column B.
Enter the following in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim A1 As Range, B As Range
Set A1 = Range("A1")
Set B = Range("B:B")
If Intersect(Target, A1) Is Nothing Then Exit Sub
Application.EnableEvents = False
If A1.Value = "proportional" Then
B.NumberFormat = "0.00%"
Else
B.NumberFormat = "General"
End If
Application.EnableEvents = True
End Sub


Because it is worksheet code, it is very easy to install and automatic to use:

1. right-click the tab name near the bottom of the Excel window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu201002


"michelle439731" wrote:

Good afternoon,

I have an array of numbers in excel. I want then to display as percentage
if I've selected "proportional" from a drop down menu. I want them to
display as a number (0.00 for example) if I select "absolute" these are the
only two options in the menu.

I'ved tried using the Format code help in Excel but I can't manuipulat it to
get it to work how I want.

Any help will be greatly apprecaited.

Thank you!

Michelle

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formating on Several Cells Damon Excel Discussion (Misc queries) 6 June 9th 09 06:58 PM
Conditional Formating in Blank Cells TF Excel Worksheet Functions 4 May 29th 09 10:55 PM
conditional formating cells i Excel based on other cells values Elias Petursson Excel Worksheet Functions 3 May 23rd 06 06:45 PM
Conditional Formating for Formula Cells Andrew Heath Excel Discussion (Misc queries) 2 September 29th 05 01:40 PM
HELP ME PLEASE!! CONDITIONAL FORMATING HIGHLIGHTING CELLS. ANDREW_B Excel Discussion (Misc queries) 1 December 2nd 04 04:12 PM


All times are GMT +1. The time now is 11:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"