View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JW[_2_] JW[_2_] is offline
external usenet poster
 
Posts: 638
Default Making all past dates bold, looping

You have a Do Loop that is doing nothing but cycling through the same
cell over and over again. No need for the Do Loop. Try this:
Sub Button_Click()
Dim currentDate As Date
currentDate = Date
For Each c In Range("D5:D369")
If Not c = currentDate Then
c.Font.Color = RGB(0, 255, 0)
c.Locked = True
c.Font.Bold = True
End If
Next c
End Sub

Memento wrote:
Hello guys,

I'm am trying to lock all cell, and make cell content bold until the date of
today is encountered. the range contains dates in the default date format
(this is European style date formatting, thus dd/mm/yyyy). However, it keeps
on looping...

any suggestions about this code?

Sub Button_Click()
Dim currentDate As Date
currentDate = Date

For Each c In Range("D5:D369")
Do Until c = currentDate
c.Font.Color = RGB(0, 255, 0)
c.Locked = True
c.Font.Bold = True
Loop
Next c
End Sub