Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Format a cell

Hi all,

Got a questions which i have a problem with.

How do I display 0.0025 as 2.5 per thousand in excel.

i.e. I type in 0.0025 and the cell shows 2.5 per thousand.

Will appreciate anybody's help.

Thanks
Pantelis


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Format a cell

AFAIK, you can't do that with formatting. You could use a
worksheet_Change macro. Put this in the worksheet code module
(right-click on the worksheet tab and choose view code):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("A1"), .Cells) Is Nothing Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
.Value = Format(.Value * 1000, "0.0") & _
" per thousand"
Application.EnableEvents = True
End If
End If
End With
End Sub



In article ,
"pantelis" wrote:

Hi all,

Got a questions which i have a problem with.

How do I display 0.0025 as 2.5 per thousand in excel.

i.e. I type in 0.0025 and the cell shows 2.5 per thousand.

Will appreciate anybody's help.

Thanks
Pantelis


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Format a cell

Thanks for the reply,

I have done what you said but I cant get it to work for some reason. I
simply copy this code into the sheets VBA but nothing happens.

Could you please help
Thanks
Pantelis

"JE McGimpsey" wrote in message
...
AFAIK, you can't do that with formatting. You could use a
worksheet_Change macro. Put this in the worksheet code module
(right-click on the worksheet tab and choose view code):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("A1"), .Cells) Is Nothing Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
.Value = Format(.Value * 1000, "0.0") & _
" per thousand"
Application.EnableEvents = True
End If
End If
End With
End Sub



In article ,
"pantelis" wrote:

Hi all,

Got a questions which i have a problem with.

How do I display 0.0025 as 2.5 per thousand in excel.

i.e. I type in 0.0025 and the cell shows 2.5 per thousand.

Will appreciate anybody's help.

Thanks
Pantelis




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Format a cell

Make sure you put the code in a *worksheet* code module, not a regular
code module (as I told you before), and that you adjust the range for
your target (I used "A1").

In article ,
"pantelis" wrote:

I have done what you said but I cant get it to work for some reason. I
simply copy this code into the sheets VBA but nothing happens.

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
Lock Cell Format - Allow copy and paste of data without format change Chris12InKC Excel Worksheet Functions 2 May 9th 23 07:42 PM
cell format - remove cell format pattern without effecting colors Bas Excel Discussion (Misc queries) 1 March 23rd 09 02:54 PM
Can cell format come from and change with reference cell format jclouse Excel Discussion (Misc queries) 1 November 29th 06 03:20 AM
Custom Cell format to mimic time format [email protected] Excel Discussion (Misc queries) 6 November 7th 06 09:17 PM
How do I copy data in single cell format to a merged cell format Paul Excel Discussion (Misc queries) 1 June 27th 05 11:00 AM


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