Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The original is case sensative. Since the question was posted twice, a
similar answer was posted in response to the second and the OP came back and said the code did nothing. My assumption was that it was a case issue. first I posted is case insensitive and looks for the string "date" in content of the cell, so it could be too broad. However, it would work with spaces on either or both ends. the second is case insensitive and looks for the exact term date. It would falter if there were spaces on either or both ends -- Regards, Tom Ogilvy "Chrissy" wrote in message ... Tom, Care to discuss and compare the three approaches shown here? Chrissy. Tom Ogilvy wrote A possible alleviation of the problem you might have as you stated in your next post: Sub formatDateCols() Dim c As Range For Each c In ActiveSheet.Range("1:1") If Instr(1,c, "date",vbTextCompare) Then c.EntireColumn.NumberFormat = "dd/mm/yy" End If Next End Sub or Sub formatDateCols() Dim c As Range For Each c In ActiveSheet.Range("1:1") If strcomp(c, "date",vbTextCompare) = 0 Then c.EntireColumn.NumberFormat = "dd/mm/yy" End If Next End Sub Sub formatDateCols() Dim c As Range For Each c In ActiveSheet.Range("1:1") If c = "Date" Then c.EntireColumn.NumberFormat = "dd/mm/yy" End If Next End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
conditional formatting for cell date to equal today's date | Excel Worksheet Functions | |||
Date value conditional formatting or Macro | Excel Discussion (Misc queries) | |||
Date Formatting in a Macro | Excel Discussion (Misc queries) | |||
formatting date-time values in macro | Excel Worksheet Functions | |||
How do I set a date range for conditional formatting in a macro? | Excel Worksheet Functions |