Select today's date

Reec0n

New Member
Joined
Jan 30, 2017
Messages
20
I have a sheet with dates for the whole year running from B2 all the way to NB2 for all of 2018.

When I open the sheet I would like today's the date to be highlighted and potentially the whole column.

If it's easy to simply do the date, that will suffice.

tia all
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Right click the tab name, select "View Code" and paste the following:

Code:
Private Sub Worksheet_Activate()

Cells(2, Date - Range("B2").Value + 2).EntireColumn.Select

End Sub

WBD
 
Upvote 0
Another alternative:
Code:
Private Sub Worksheet_Activate()
    Dim LastRow As Long
    LastRow = Sheets("Sheet1").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim foundDate As Range
    Set foundDate = Sheets("Sheet1").Rows(2).Find(Date, LookIn:=xlFormulas, lookat:=xlWhole)
    If Not foundDate Is Nothing Then
        Sheets("Sheet1").Range(Sheets("Sheet1").Cells(2, foundDate.Column), Sheets("Sheet1").Cells(LastRow, foundDate.Column)).Interior.ColorIndex = 3
    End If
End Sub
Place the macro in the worksheet code module.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top