Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default EXCEL FORMATTING

I have cols of data (one would be percent change) where I
would divide. I want all of the cells to display right
aligned. I also want to change the "division by zero"
result to be changed to a "-", and centered. I can do it
when I want a dollar sign or no sign...with an if statment
to change the div by zero and the accounting format.
I want to it to occur on the percent columns as well, and
can't figure out how...the "-" never comes out centered.
I think I just need a custom format but can't seem to get
it.
Please help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default EXCEL FORMATTING

This may provide some food for thought,

Column A : Contains Numerators
Column B : Contains Denominators
Column D: Contains Formula : =If(Bn < 0,An/Bn,"-") example :
=If(B7<0,A7/B7,"-")

Then the macro to try is,
-------------------------------------
Private Sub Worksheet_Calculate()

Dim iRow As Integer

For iRow = 2 To 20
If Cells(iRow, 4).Value = "-" Then
Cells(iRow, 4).HorizontalAlignment = xlCenter
Else
Cells(iRow, 4).HorizontalAlignment = xlRight
Cells(iRow, 4).NumberFormat = "#.0%"
End If
Next iRow
End Sub
------------------------------------------
I think this would be better if incorporated into a Function, but I couldn't
get that to work


"TC" wrote in message
...
I have cols of data (one would be percent change) where I
would divide. I want all of the cells to display right
aligned. I also want to change the "division by zero"
result to be changed to a "-", and centered. I can do it
when I want a dollar sign or no sign...with an if statment
to change the div by zero and the accounting format.
I want to it to occur on the percent columns as well, and
can't figure out how...the "-" never comes out centered.
I think I just need a custom format but can't seem to get
it.
Please help!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default EXCEL FORMATTING

Wow! I think that is above me.
I had the column D part already.
There must be a way to do it with a format because the
accounting format does it exactly how I want it...I just
cannot get the percent to do it.
ANYBODY ELSE???

-----Original Message-----
This may provide some food for thought,

Column A : Contains Numerators
Column B : Contains Denominators
Column D: Contains Formula : =If(Bn < 0,An/Bn,"-")

example :
=If(B7<0,A7/B7,"-")

Then the macro to try is,
-------------------------------------
Private Sub Worksheet_Calculate()

Dim iRow As Integer

For iRow = 2 To 20
If Cells(iRow, 4).Value = "-" Then
Cells(iRow, 4).HorizontalAlignment = xlCenter
Else
Cells(iRow, 4).HorizontalAlignment = xlRight
Cells(iRow, 4).NumberFormat = "#.0%"
End If
Next iRow
End Sub
------------------------------------------
I think this would be better if incorporated into a

Function, but I couldn't
get that to work


"TC" wrote in message
...
I have cols of data (one would be percent change) where

I
would divide. I want all of the cells to display right
aligned. I also want to change the "division by zero"
result to be changed to a "-", and centered. I can do

it
when I want a dollar sign or no sign...with an if

statment
to change the div by zero and the accounting format.
I want to it to occur on the percent columns as well,

and
can't figure out how...the "-" never comes out centered.
I think I just need a custom format but can't seem to

get
it.
Please help!



.

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
Formatting lost when saving excel 2003 file using excel 2007 Anamika Excel Discussion (Misc queries) 1 December 29th 08 04:24 PM
"Excel encountered an error and had to remove some formatting toavoid corrupting the workbook. Please re-check your formatting carefully." Greg Lovern Excel Discussion (Misc queries) 0 July 18th 08 09:42 PM
Saving Excel 2007 conditional formatting in Excel 2003 format [email protected] Excel Discussion (Misc queries) 0 March 28th 08 06:42 AM
Protect Cell Formatting including Conditional Formatting Mick Jennings Excel Discussion (Misc queries) 5 November 13th 07 05:32 PM
expanding custom formatting without removing existing cell formatting? Keith Excel Worksheet Functions 3 December 27th 06 01:54 PM


All times are GMT +1. The time now is 03:32 PM.

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

About Us

"It's about Microsoft Excel"