A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Custom Formating Cells



 
 
Thread Tools Display Modes
  #1  
Old December 14th, 2007, 04:36 PM posted to microsoft.public.excel.worksheet.functions
JohnWFUBMC
external usenet poster
 
Posts: 1
Default Custom Formating Cells

I want to format a cell so that when I type a number into that cell it will
take the absolute value of that number and then multiple it by 1000. Is
there anyway to do this without generating a formula in a new cell?
  #2  
Old December 14th, 2007, 05:08 PM posted to microsoft.public.excel.worksheet.functions
ryguy7272
external usenet poster
 
Posts: 1,593
Default Custom Formating Cells

This is called 'event code'. Copy the code, right-click the tab, and paste
it into the window that opens up:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
If IsNumeric(Target) Then
Application.EnableEvents = False
Target.Value = Abs(Target.Value * 1000)
Application.EnableEvents = True
End If
End If
End Sub

Notice, the range is A1:A10; change to suit your needs...

Regards,
Ryan---

--
RyGuy


"JohnWFUBMC" wrote:

I want to format a cell so that when I type a number into that cell it will
take the absolute value of that number and then multiple it by 1000. Is
there anyway to do this without generating a formula in a new cell?

  #3  
Old December 14th, 2007, 06:35 PM posted to microsoft.public.excel.worksheet.functions
Gord Dibben
external usenet poster
 
Posts: 20,252
Default Custom Formating Cells

You can't "format" a cell to multiply itself by 1000

You could use event code to do this.

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:A10"
Dim cell As Range
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
For Each cell In Target
If cell.Value "" Then
cell.Value = cell.Value * 1000
cell.NumberFormat = "###0.00"
End If
Next cell
End If
ws_exit:
Application.EnableEvents = True
End Sub

Right-click on the sheet tab and "View Code". Copy/paste the above into that
sheet module.

Adjust range and numberformat to suit.


Gord Dibben MS Excel MVP

On Fri, 14 Dec 2007 08:36:08 -0800, JohnWFUBMC
wrote:

I want to format a cell so that when I type a number into that cell it will
take the absolute value of that number and then multiple it by 1000. Is
there anyway to do this without generating a formula in a new cell?


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:21 PM.


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