Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Formatting Cells Dependent on Contents

Hi Danny,

Try something like this...

Regards,
Colo
http://www.interq.or.jp/sun/puremis/...astersLink.htm

'---------------------------------------------------------------------------
------------

'Place this code in Thisworkbook module
'Assume you have a worksheet named ("CustomFormat")
'A Column of Sheets("CustomFormat") has name list like house, school...
'B Column has been colored by Interior.ColorIndex


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim lngTemp As Long
For Each c In Target
lngTemp = MyFormat(c, c.Value)
If lngTemp < 0 Then c.Interior.ColorIndex = lngTemp
Next
End Sub


Private Function MyFormat(ByVal Target As Range, ByVal strSeq As String) As
Long
Dim ret
With Sheets("CustomFormat")
ret = Application.Match(strSeq, .Columns(1), 0)
If Not IsError(ret) Then
MyFormat = .Cells(ret, 2).Interior.ColorIndex
Else
MyFormat = 0
End If
End With
End Function


"Danny" wrote in message
...
Is their an easy piece of code which could be used on an
entire worksheet to format the cells dependent on their
content. I.e if a cell contains the text 'house' then the
cell has a red background etc. for about 50 conditions.
This is similar to conditional formating but i need more
than 3 conditions and the code should update the colour of
the cell if the content changes?

I am sure this must be fairly simple, but when i have
aksed in the past the code i received was far too complex
and did not update? I am fairly new to the code side of
Excel so please keep any examples simple.

Danny.


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
Directing cell contents to one of two cells dependent on its value Debi Excel Worksheet Functions 1 April 15th 10 03:13 PM
directing cell contents dependent on its value Debi Excel Worksheet Functions 2 April 15th 10 09:58 AM
Data Validation list dependent on contents of another cell Scorer150 Excel Discussion (Misc queries) 2 February 7th 08 12:13 AM
Formatting Cells Dependent on Contents Patrick Molloy Excel Programming 0 November 27th 03 01:36 PM
Formatting Cells Dependent on Contents Bill Manville Excel Programming 0 November 27th 03 01:36 PM


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