VBA macro button to select todays date changes formatting???

willhelm654

New Member
Joined
Jan 11, 2020
Messages
7
Office Version
  1. 2013
Platform
  1. Windows
Hello I hope somebody can shed some light for me.

I have a macro button on my s/sheet that runs pretty well to highlight todays date within a row. However it also red borders the left and right side of the column below and im not sure why? It is quite useful and I would like to have the same funciton on my second sheet but it only extends two rows as seen below.

Code is:
VBA Code:
Sub Select_Today()
Dim C As Variant
With ActiveSheet
    With .Range("C3:HK3")
        C = Application.Match(CLng(Date), .Cells, 0)
        If IsNumeric(C) Then
            .Item(1, C).Select
        Else
            MsgBox "Date is not in column range C3:HK3."
        End If
    End With
End With
End Sub

Here is a screen shot to explain:
Capture.PNG

Second Sheet:
Capture.PNG
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How are you highlighting the cell?

Are you using conditional formatting? There's nothing in your code that could be doing it
 
Upvote 0
Do you have any event code in that sheets module, or in the ThisWorkbook module?
 
Upvote 0
Do you have any event code in that sheets module, or in the ThisWorkbook module?

No Event code that I can see. the only Vba running is the one above. File is here if you can have a look. Capacity plan
Its got me stumped, I dont know if it is a function of Excel 2013?
 
Upvote 0
Rich (BB code):
No conditional formatting this is why i am so confused....
Your file contains Conditional Formatting which is adding the red borders.
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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