black border

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
667
Office Version
  1. 365
Platform
  1. Windows
hi,

i have the following code:-

Code:
Sub FormatRange()    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim lCol As Long
    lCol = ActiveSheet.UsedRange.Columns.Count
    With Range(Cells(1, 1), Cells(LastRow, lCol))
        .Rows.RowHeight = 20
        .Columns.ColumnWidth = 14
        .Font.Name = "Calibri"
        .Font.Size = 20
        .Borders.LineStyle = xlDouble
    End With
    Application.ScreenUpdating = True
End Sub


how do I make the 'border's black (please )?

MTIA
Trevor3007
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Maybe..

Code:
Sub FormatRange()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim lCol As Long
    lCol = ActiveSheet.UsedRange.Columns.Count
    With Range(Cells(1, 1), Cells(LastRow, lCol))
        .Rows.RowHeight = 20
        .Columns.ColumnWidth = 14
        .Font.Name = "Calibri"
        .Font.Size = 20
        With .Borders
            .LineStyle = xlDouble
            .ColorIndex = 0
            .TintAndShade = 0
        End With
    End With
    Application.ScreenUpdating = True
End Sub

If not try changing the ColorIndex to 1
 
Upvote 0
Maybe..

Code:
Sub FormatRange()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim lCol As Long
    lCol = ActiveSheet.UsedRange.Columns.Count
    With Range(Cells(1, 1), Cells(LastRow, lCol))
        .Rows.RowHeight = 20
        .Columns.ColumnWidth = 14
        .Font.Name = "Calibri"
        .Font.Size = 20
        With .Borders
            .LineStyle = xlDouble
            .ColorIndex = 0
            .TintAndShade = 0
        End With
    End With
    Application.ScreenUpdating = True
End Sub

If not try changing the ColorIndex to 1



morning MARK858 & thanks ,

works fine, just wondered is it possible to restrict it to only work in the range:-
A3-k7999?

MTIA
Trevor3007
 
Upvote 0
Just change your With statement from

Code:
With Range(Cells(1, 1), Cells(LastRow, lCol))
to
Code:
With Range("A3:K7999")

And do away with the code below

Code:
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim lCol As Long
    lCol = ActiveSheet.UsedRange.Columns.Count
 
Last edited:
Upvote 0
hi,

Thanks again. It works but it 'unhides' my 'hidden' columns????

KR
Trevor3007
 
Upvote 0
Try...

Code:
With Range("A3:K7999").SpecialCells(12)
 
Upvote 0
GREAT!!! works treat.

is it possible that it will only grid the the next 'ungrided' line or lines ?


So for example a3- k150 are grided, but I add data into a151-k155 . I need to grid a3-k155?
Hoping this makes sense?

KR
Trevor3007
 
Upvote 0
How are you adding the data? manually,by code or formula?
 
Upvote 0
Hi Mark,

thanks again fo your help.
apart from a vlookup , the odd 'if' statement all other is added manually.


I had a look search and found this:-
Sub XYZ()
ActiveSheet.UsedRange.Borders.Weight = xlThick
End Sub

could you sorted so it only does the applicbale range & keeep the hidden cols 'hidden'?
 
Last edited:
Upvote 0
It is not the borders code that makes your columns visible, it is the .Columns.ColumnWidth = 14 in your other code that makes them visible.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,429
Members
448,961
Latest member
nzskater

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