Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Conditional Numerical Formatting

I'd like the number format for the value in cell a3 to be a general number if
a1 is empty and i'd like the format to be a percentage if a1 contains a
value.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Conditional Numerical Formatting

Since one cell can't change another cell's formatting, this will require
an Event macro.

Put this in your worksheet code module (right-click on the worksheet tab
and choose "View Code")"


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target(1)
If .Address(False, False) = "A1" Then
If IsEmpty(.Value) Then
Range("A3").NumberFormat = "General"
Else
Range("A3").NumberFormat = "0%"
End If
End If
End With
End Sub





In article ,
Qaspec wrote:

I'd like the number format for the value in cell a3 to be a general number if
a1 is empty and i'd like the format to be a percentage if a1 contains a
value.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Conditional Numerical Formatting

What if A1 was on sheet1("Data") and A3 were on sheet2("Daily")? How would I
change the code?

"JE McGimpsey" wrote:

Since one cell can't change another cell's formatting, this will require
an Event macro.

Put this in your worksheet code module (right-click on the worksheet tab
and choose "View Code")"


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target(1)
If .Address(False, False) = "A1" Then
If IsEmpty(.Value) Then
Range("A3").NumberFormat = "General"
Else
Range("A3").NumberFormat = "0%"
End If
End If
End With
End Sub





In article ,
Qaspec wrote:

I'd like the number format for the value in cell a3 to be a general number if
a1 is empty and i'd like the format to be a percentage if a1 contains a
value.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Conditional Numerical Formatting

Put the code in the Data sheets
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
set sh = Worksheets("Daily")
With Target(1)
If .Address(False, False) = "A1" Then
If IsEmpty(.Value) Then
sh.Range("A3").NumberFormat = "General"
Else
sh.Range("A3").NumberFormat = "0%"
End If
End If
End With
End Sub

--
Regards,
Tom Ogilvy

"Qaspec" wrote in message
...
What if A1 was on sheet1("Data") and A3 were on sheet2("Daily")? How would

I
change the code?

"JE McGimpsey" wrote:

Since one cell can't change another cell's formatting, this will require
an Event macro.

Put this in your worksheet code module (right-click on the worksheet tab
and choose "View Code")"


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target(1)
If .Address(False, False) = "A1" Then
If IsEmpty(.Value) Then
Range("A3").NumberFormat = "General"
Else
Range("A3").NumberFormat = "0%"
End If
End If
End With
End Sub





In article ,
Qaspec wrote:

I'd like the number format for the value in cell a3 to be a general

number if
a1 is empty and i'd like the format to be a percentage if a1 contains

a
value.





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
Excel Numerical Formatting Brent Lee Excel Discussion (Misc queries) 3 January 23rd 09 02:34 AM
Conditional Formatting; finding numerical data in mixed text. Philonis Excel Discussion (Misc queries) 2 June 5th 07 11:57 PM
Custom Currency/Numerical Formatting? John Mann Excel Discussion (Misc queries) 6 February 23rd 07 11:40 PM
Formatting columns with either a date OR a numerical figure Terry Winter Excel Worksheet Functions 1 October 29th 06 11:45 AM
can a conditional formulas be setup using text to get a numerical abe Excel Worksheet Functions 1 April 5th 06 06:43 PM


All times are GMT +1. The time now is 05:52 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"