Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default automatically format cell based on content of another cell

I am trying to automatically format a cell to display its contents in either
a date or number format based on which letter is displayed in another cell in
the same row. I.E. cell 5a value is M, I need cell 5f to be in MMMYY
format.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default automatically format cell based on content of another cell

You would need to use the Change event: copy the code below, right -click
the sheet tab, select "View Code" and paste the code into the window that
appears. I have included a second condition (N) to show how to do multiple
formats based on entries in column A.

HTH,
Bernie
MS Excel MVP


Private Sub Worksheet_Change(ByVal Target As Range)
Dim myCell As Range
If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
For Each myCell In Intersect(Target, Range("A:A"))
If UCase(myCell.Value) = "M" Then
Cells(myCell.Row, 6).NumberFormat = "MMM YY"
End If
If UCase(myCell.Value) = "N" Then
Cells(myCell.Row, 6).NumberFormat = "0.00"
End If
Next myCell
End Sub


"Blustreaker" wrote in message
...
I am trying to automatically format a cell to display its contents in
either
a date or number format based on which letter is displayed in another cell
in
the same row. I.E. cell 5a value is M, I need cell 5f to be in MMMYY
format.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default automatically format cell based on content of another cell

Bernie,

THanks for your help, Your a prince!!!!

"Bernie Deitrick" wrote:

You would need to use the Change event: copy the code below, right -click
the sheet tab, select "View Code" and paste the code into the window that
appears. I have included a second condition (N) to show how to do multiple
formats based on entries in column A.

HTH,
Bernie
MS Excel MVP


Private Sub Worksheet_Change(ByVal Target As Range)
Dim myCell As Range
If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
For Each myCell In Intersect(Target, Range("A:A"))
If UCase(myCell.Value) = "M" Then
Cells(myCell.Row, 6).NumberFormat = "MMM YY"
End If
If UCase(myCell.Value) = "N" Then
Cells(myCell.Row, 6).NumberFormat = "0.00"
End If
Next myCell
End Sub


"Blustreaker" wrote in message
...
I am trying to automatically format a cell to display its contents in
either
a date or number format based on which letter is displayed in another cell
in
the same row. I.E. cell 5a value is M, I need cell 5f to be in MMMYY
format.




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
conditional formatting one cell based on content of another cell Chris Adolph Excel Discussion (Misc queries) 3 June 6th 07 06:52 PM
Conditional cell background formatting, based on cell content nosivad Excel Discussion (Misc queries) 5 February 11th 06 11:12 PM
Cond Format & helper-cell based "duplicate rec" tricked by content Dennis Excel Discussion (Misc queries) 3 December 16th 05 06:55 PM
Cell Formula reference to cell Based On third Cell Content Gabriel Excel Discussion (Misc queries) 1 February 11th 05 06:36 AM
Cell Formula reference to cell Based On third Cell Content Gabriel Excel Discussion (Misc queries) 0 February 11th 05 05:35 AM


All times are GMT +1. The time now is 07:14 AM.

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"