PC Review


Reply
Thread Tools Rate Thread

associate cell format

 
 
=?Utf-8?B?bWFzc2k=?=
Guest
Posts: n/a
 
      26th Oct 2006
Hi,
I would like to associate a particular format to a cell depending on the
text contained by the cell next to it. so if for example cell A1 has date and
time i would like to have a particular format in B1; if A2 has number of
people i would kie to have in B2 an other type of format.
is that possible?
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      26th Oct 2006
One way

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H10" '<=== change to suit

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
Select Case Target.Value
Case 1: Target.Offset(0, 1).NumberFormat = "dd mmm yyyy"
Case 2: Target.Offset(0, 1).NumberFormat = "#,##0.00"
Case 3: Target.Offset(0, 1).NumberFormat = "#,##0"
'etc
End Select
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"massi" <(E-Mail Removed)> wrote in message
news:B188C5EB-ECA9-4FA3-A631-(E-Mail Removed)...
> Hi,
> I would like to associate a particular format to a cell depending on the
> text contained by the cell next to it. so if for example cell A1 has date

and
> time i would like to have a particular format in B1; if A2 has number of
> people i would kie to have in B2 an other type of format.
> is that possible?



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cell format -> remove cell format pattern without effecting colors Bas Microsoft Excel Misc 1 23rd Mar 2009 02:54 PM
Associate a cell with a number ?? jladika Microsoft Excel Discussion 6 11th Jun 2004 06:09 AM
Re: Associate cell with micro? CLR Microsoft Excel Misc 0 5th Jun 2004 03:46 AM
Re: Associate cell with micro? Dave Peterson Microsoft Excel Misc 0 5th Jun 2004 03:23 AM
Associate cell with micro? jeff Microsoft Excel Misc 0 4th Jun 2004 09:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:08 PM.