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

willhelm654

New Member
Joined
Jan 11, 2020
Messages
5
Office Version
2013
Platform
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
 

Some videos you may like

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

juddaaaa

Board Regular
Joined
Jan 4, 2020
Messages
208
Office Version
365
Platform
Windows
How are you highlighting the cell?

Are you using conditional formatting? There's nothing in your code that could be doing it
 

willhelm654

New Member
Joined
Jan 11, 2020
Messages
5
Office Version
2013
Platform
Windows
How are you highlighting the cell?

Are you using conditional formatting? There's nothing in your code that could be doing it
No conditional formatting this is why i am so confused....
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
38,439
Office Version
365
Platform
Windows
Do you have any event code in that sheets module, or in the ThisWorkbook module?
 

willhelm654

New Member
Joined
Jan 11, 2020
Messages
5
Office Version
2013
Platform
Windows
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?
 

footoo

Well-known Member
Joined
Sep 21, 2016
Messages
2,936
Office Version
2016
Platform
Windows
Rich (BB code):
No conditional formatting this is why i am so confused....
Your file contains Conditional Formatting which is adding the red borders.
 

willhelm654

New Member
Joined
Jan 11, 2020
Messages
5
Office Version
2013
Platform
Windows
Rich (BB code):
No conditional formatting this is why i am so confused....
Your file contains Conditional Formatting which is adding the red borders.
Thank you i will double check.
 

juddaaaa

Board Regular
Joined
Jan 4, 2020
Messages
208
Office Version
365
Platform
Windows
The letters representing the weekdays are also off by 1 ;)
 

Watch MrExcel Video

Forum statistics

Threads
1,095,168
Messages
5,442,796
Members
405,197
Latest member
queryashish

This Week's Hot Topics

  • Copy entire row if CountA <>0 to another sheet
    [B]I want to copy entire row if CountA <>0 for column J7:AM7 (headers on J6:AM6) and so on till the last used cell is column D and paste the...
  • Select last used Row in Table
    I have created a Table in a Worksheet which is locked to prevent user errors and protect formula. Some of the cells require freetext entries which...
  • excel workbook: do not allow certain file name
    Hello all, Don't think this has ever been asked before, but how do I restrict file save [Before_Save Event] if the name of the file being saved...
  • fixing problem autofilter
    hello i need help about my code when i search by code in textbox it doesn't show anything this is my data [ATTACH type="full"...
  • “Weight”
    Hi, i’ve got a long sheet filled with weights such as kg,g,L & ml. i can build a formula to convert kg into g and liter into ml. How ever, my...
  • How to capitalize everything before a certain character?
    In column A, I have some text: Hello good day.mp3 Hello good day.flac etc. I'd like to capitalize everything before the period. I don't need the...
Top