macro to change colour of existing cell boarders in a sheet without effecting anything else?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

I have a sheet with loads of areas all created by someone else who did not see the importance of merging cells,

So I have boarders that I cant simply change the colour of as it takes ages.

I need a macro that can change all existing boarders either on active sheet or in a specified range say "A1:AZ100" from existing colour to RGB 191,191,191 and if possible make them all thin lines

I hope this can be done please help if you know how

thanks

Tony
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I have a sheet with loads of areas all created by someone else who did not see the importance of merging cells

Hi, isn't the important thing to remember about merged cells is that they should be avoided like the plague ;)

Here is some code you can try on a copy of your workbook.

Code:
Sub M()
Dim C As Range, V
For Each C In Range("A1:AZ100")
  For Each V In Array(xlEdgeBottom, xlEdgeTop, xlEdgeRight, xlEdgeLeft, xlDiagonalDown, xlDiagonalUp)
    If C.Borders(V).LineStyle <> xlNone Then
      C.Borders(V).Weight = xlThin
      C.Borders(V).Color = RGB(191, 191, 191)
    End If
  Next V
Next C
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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