Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default macro for conditional number formatting

Can anyone help me.

Im trying to write a macro where each time i enter text in column A it
will conditionally format the number in the same row of column C ?

The text that is entered in column A is limited to the list below.



column A(TEXT) column C(format)

ES (####.##)
NQ (####.##)
AB (####.##)
YM (####.##)
ZB (# #/32)
EC (#.####)
JY (###.##)
ED (##.###)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default macro for conditional number formatting

Scott,

Worksheet event code.

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Target.Column = 1 Then
Select Case Target.Value
Case "ES": Target.EntireRow.NumberFormat = "(####.##)"
Case "NQ": Target.EntireRow.NumberFormat = "(####.##)"
Case "AB": Target.EntireRow.NumberFormat = "(####.##)"
Case "YM": Target.EntireRow.NumberFormat = "(####.##)"
Case "ZB": Target.EntireRow.NumberFormat = "(# #/32)"
Case "EC": Target.EntireRow.NumberFormat = " (#.####)"
Case "JY": Target.EntireRow.NumberFormat = " (###.##)"
Case "ED": Target.EntireRow.NumberFormat = " (##.###)"
End Select
End If

ws_exit:
Application.EnableEvents = True
End Sub

Put it in theworksheet code module - right click on the sheet name tab, View
Code

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"scott23" wrote in message
om...
Can anyone help me.

Im trying to write a macro where each time i enter text in column A it
will conditionally format the number in the same row of column C ?

The text that is entered in column A is limited to the list below.



column A(TEXT) column C(format)

ES (####.##)
NQ (####.##)
AB (####.##)
YM (####.##)
ZB (# #/32)
EC (#.####)
JY (###.##)
ED (##.###)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro for conditional number formatting

How would i modify this so that instead of the entire row
being formatted, it would only be columns E/F/H/I
Thanks

-----Original Message-----
Scott,

Worksheet event code.

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Target.Column = 1 Then
Select Case Target.Value
Case "ES": Target.EntireRow.NumberFormat

= "(####.##)"
Case "NQ": Target.EntireRow.NumberFormat

= "(####.##)"
Case "AB": Target.EntireRow.NumberFormat

= "(####.##)"
Case "YM": Target.EntireRow.NumberFormat

= "(####.##)"
Case "ZB": Target.EntireRow.NumberFormat

= "(# #/32)"
Case "EC": Target.EntireRow.NumberFormat = "

(#.####)"
Case "JY": Target.EntireRow.NumberFormat = "

(###.##)"
Case "ED": Target.EntireRow.NumberFormat = "

(##.###)"
End Select
End If

ws_exit:
Application.EnableEvents = True
End Sub

Put it in theworksheet code module - right click on the

sheet name tab, View
Code

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"scott23" wrote in message
. com...
Can anyone help me.

Im trying to write a macro where each time i enter text

in column A it
will conditionally format the number in the same row of

column C ?

The text that is entered in column A is limited to the

list below.



column A(TEXT) column C(format)

ES (####.##)
NQ (####.##)
AB (####.##)
YM (####.##)
ZB (# #/32)
EC (#.####)
JY (###.##)
ED (##.###)



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default macro for conditional number formatting

See response to other question.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"scott23" wrote in message
...
How would i modify this so that instead of the entire row
being formatted, it would only be columns E/F/H/I
Thanks

-----Original Message-----
Scott,

Worksheet event code.

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Target.Column = 1 Then
Select Case Target.Value
Case "ES": Target.EntireRow.NumberFormat

= "(####.##)"
Case "NQ": Target.EntireRow.NumberFormat

= "(####.##)"
Case "AB": Target.EntireRow.NumberFormat

= "(####.##)"
Case "YM": Target.EntireRow.NumberFormat

= "(####.##)"
Case "ZB": Target.EntireRow.NumberFormat

= "(# #/32)"
Case "EC": Target.EntireRow.NumberFormat = "

(#.####)"
Case "JY": Target.EntireRow.NumberFormat = "

(###.##)"
Case "ED": Target.EntireRow.NumberFormat = "

(##.###)"
End Select
End If

ws_exit:
Application.EnableEvents = True
End Sub

Put it in theworksheet code module - right click on the

sheet name tab, View
Code

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"scott23" wrote in message
. com...
Can anyone help me.

Im trying to write a macro where each time i enter text

in column A it
will conditionally format the number in the same row of

column C ?

The text that is entered in column A is limited to the

list below.



column A(TEXT) column C(format)

ES (####.##)
NQ (####.##)
AB (####.##)
YM (####.##)
ZB (# #/32)
EC (#.####)
JY (###.##)
ED (##.###)



.



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
Need help with macro for conditional formatting using number forma Kathy Excel Worksheet Functions 1 March 23rd 10 11:33 AM
whole number conditional formatting danlinksman Excel Worksheet Functions 9 April 24th 07 12:50 AM
Whole Number Conditional Formatting Kelly Excel Discussion (Misc queries) 3 March 30th 06 01:14 PM
Conditional Number Formatting Neda Excel Discussion (Misc queries) 2 December 20th 05 02:39 AM
odd and even number conditional formatting vishu Excel Discussion (Misc queries) 3 October 18th 05 09:00 AM


All times are GMT +1. The time now is 08:20 AM.

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"