Mimic Coloured boxes around precedent cells with VBA

prograplex

New Member
Joined
May 21, 2014
Messages
6
Hi,

I'm trying to mimic the coloured boxes that appear around precedent cells when you edit a formula. I can use VBA to colour the borders, but I like the style with small boxes on the 4 corners of the range as it allows the colour to be seen even if that cell is selected. Is there any way to choose this style as the border style? Or a way to make a custom border? Or a way to access that kind of bordering on precedent cells?


Thanks for the help.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hi and welcome to the MrExcel Message Board.

My precedent cells have only one square at the bottom right hand side.

However, you can use a Shape to highlight a cell. I created a shapr called Rectangle 1, gave it the formatting I liked then used this code in the worksheet module to make it highlight the selected cell:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Count = 1 Then
        With Shapes("Rectangle 1")
            .Top = Target.Top
            .Left = Target.Left
            .Width = Target.Width
            .Height = Target.Height
        End With
    End If
End Sub
 
Upvote 0
I was talking more along the lines of this:

b765402c7a01b5b1bccd77defc035f65.png




Although I guess I could achieve this with newly created shapes. Will give it a try and post my solution if it works.

Thanks
 
Upvote 0

Forum statistics

Threads
1,216,119
Messages
6,128,946
Members
449,480
Latest member
yesitisasport

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