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

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default associate cell format

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" wrote in message
...
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
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
Associate Data Across Rows brookruns Excel Discussion (Misc queries) 2 October 22nd 07 09:27 PM
How can I associate a formula with Checkboxes Todd Nelson Excel Discussion (Misc queries) 2 October 3rd 06 07:33 PM
ASSOCIATE number TO VALUE zsozi Excel Discussion (Misc queries) 2 July 30th 06 06:18 PM
associate color stats Excel Discussion (Misc queries) 1 March 16th 06 10:33 PM
Associate name with email jswafa Excel Discussion (Misc queries) 2 March 10th 05 07:23 PM


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