Declare cell / border format to be reused

Martynrbell

New Member
Joined
Apr 11, 2016
Messages
38
Office Version
  1. 365
Platform
  1. Windows
I'm writing some code where each result needs the colour changing and the border setting.

The colour is fine as it's only 1 extra line of code however the border is a few.

With rng.Borders
.LineStyle = xlContinuous
.Color = vbRed
.Weight = xlThin
End With
Is there a simpler way to set the border with fewer lines?

Eg range.borderset= full and black

Or can I declare something prior that I can recall

Range.declaredvarforborder

I'm trying to tidy up and make it easier for me to read.

Cheers
 
Last edited:

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Not really that's about as simple as Borders get !!
Have you considered maybe coding formats from an existing formatted range

Code:
Range("A1:A2").Copy
rng.PasteSpecial Paste:=xlPasteFormats
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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