I need help creating a macro in which the border thickness would appear on a list of columns that contains one cell with current date. When I tried to conditional formatting the borders, I realized there wasn't a option for thick borders.
For example, I have a row that lists all the dates. If today's date lands in one of the rows, I want that column to be border thick. The dates are from B2:VG2 and the columns that I want that current date to be thick is from B5:VG58; however, I only want one entire column to be thick that matches the current date. Any help is greatly appreciated. Thank you!
Macro for Conditional Formatting Thick Borders
-
k78 -
March 26, 2018 at 6:45 PM -
Thread is marked as Resolved.
-
-
-
-
A case statement does not work in that manner. Change the case to a for ... each ... next loop and you should be fine.
-
Thank you for the reply, if I may ask, Why doesn't the Case statement work? I'm not understanding how it structurally doesn't fit.
-
think of Case like IF statement but instead of true or false, you can have multiple answers or ranges
like in the linked example
http://www.excel-easy.com/vba/examples/select-case.htmlif you really wanted to use case in your scenario...firstly i must assume B2:Vg2 is a merged cell
then you can use it like so...
CodeSub ThickBorders() With Range("B2:VG58") Select Case Range("B2") Case Is = date .Borders(xlEdgeTop).Weight = xlThick .Borders(xlInsideHorizontal).Weight = xlThick .Interior.ColorIndex = 3 End Select End With End Sub
but if you only have 1 case.....then you might as well have IF statement instead
-
-
Thank you so much. I didn't realize Today isn't a function in VBA. TBH, I didn't really know how to use a IF function. I thought the case function would be sufficient for the statement. Didn't know the case function was meant for different inputs and outputs.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!