autogrid

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
675
Office Version
  1. 365
Platform
  1. Windows
good afternoon,

i hope there is someone who can solve this excel problem i have.

As I admin assistant one of my many jobs is to amend worksheets to the 'Business' format/style....

rows height = 20

column width = 14

font = Calibri

font size = 14


although I have a macro to do the above, the issue is that all the workbooks need to have a border . This is fine if the workbook only has a few / rows . But most of them have 2000+ & 26 + columns.

What I require is well out of my macro/VB knowledge ... is it possible to run some VB that will automatically find the last column & row containing text & then border the applicable & return to cell A1 & also the afore mention :-

rows height = 20

column width = 14

font = Calibri

font size = 14 .


thank you for your assistance & I look forward to your reply.

KR
Trevor 3007
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try:
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 = 14
        .Borders.LineStyle = xlContinuous
    End With
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
How about
Code:
Sub MyFormat()
   Dim lr As Long, lc As Long
   lr = Cells.Find("*", , xlValues, , xlByRows, xlPrevious, , , False).row
   lc = Cells.Find("*", , xlValues, , xlByColumns, xlPrevious, , , False).Column
   With Range("A1", Cells(lr, lc))
      .RowHeight = 20
      .ColumnWidth = 14
      .Font.name = "Calibri"
      .Font.size = 14
      .BorderAround xlContinuous, xlMedium, xlColorIndexAutomatic
   End With
End Sub
As you haven't said what border you want I've guessed.

As mumps beat me to it, I've changed mine to give an outer border only
 
Last edited:
Upvote 0
Thank you...yours works a treat too. I required all cells to have a border. Sorry if I had not stated this.

have a great day,
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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