Need help with CASE function

PierreT

New Member
Joined
Nov 7, 2014
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a simple excel sheet with all of 2017 calendar dates on it from A5:A369. When I open the excel sheet, it finds today's date in column A and bolds the cell, increases the size and borders it.

1. What I would like to add to the current code is: once it finds the date, I would like to apply all the changes that occur in Column A (bold, size and border) through Column F instead of just one column. I can't seem to figure out how.

2. Finally, if within the row there is a specific word in column D, I would like the column A:F of that row to be highlighted a certain color.

here is what I have so far:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
For Each cell In ActiveSheet.Range("A1:A400")
    If cell.Value = [Today()] Then
       cell.Borders(xlDiagonalDown).LineStyle = xlNone
       cell.Borders(xlDiagonalUp).LineStyle = xlNone
    
    With cell.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThick
    End With
    
    With cell.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThick
    End With
    
    With cell.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThick
    End With
    With cell.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThick
    End With
    
    With cell.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThick
    End With
    
    With cell.Borders(xlInsideHorizontal)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThick
    End With
    
    cell.Font.Size = 14
    cell.Font.Bold = True
    
    Dim squadron As String
    
    Select Case squadron
    
    Case "Test1"
    EntireRow.Interior.Color = 8
    Case "Test2"
    EntireRow.Interior.Color = 9
    End Select
End If
Next
End Sub

Any help would be much appreciated, Thanks
 
Thank you so much for your help. I wll be playing with the:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
and put it under Private Sub Worksheet_Activate the script didn't work. Anyhow, i'll be working on it.
Thanks again
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
If you use Activate.
When you select another sheet and then go back to your sheet with the code the script will run
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,334
Members
452,636
Latest member
laura12345

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