Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Macro for: If cell has 4 characters, make cell red

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sandeman - 22 Mar 2006 16:38 GMT
I'd like a macro to identify cells with only 4 characters (i.e. a yea
like 1989) and if the cell has only 4 characters, to make th
characters in the cell to the right of it bold red.  For example, i
cell A29 is 1933, the characters in cell B29 should be in bold red.

Thanks for your help
Carim - 22 Mar 2006 17:05 GMT
Hi Sandeman,

Give a try to following :
Private Sub Worksheet_Change(ByVal Target As Range)

Dim Cell As Range
Set Target = Range("A1:A50")
If Target Is Nothing Then
  Exit Sub
Else
   For Each Cell In Target
       If Len(Cell.Value) = 4 Then
          Cell.Offset(0, 1).Range("A1").Interior.ColorIndex = 3
       End If
       If Len(Cell.Value) <> 4 Then
          Cell.Offset(0, 1).Range("A1").Interior.ColorIndex = xlNone
       End If
   Next Cell
End If
End Sub

HTH
Carim
Sandeman - 23 Mar 2006 09:27 GMT
Wonderful.  Thank you Carim
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.