Format columns A-M only on the last row of a dynamic range

Ralmd

New Member
Joined
Oct 26, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I have 5 different worksheets in a workbook that is created by a dumped from an estimating program as a report. On these 5 sheets I have totaled the columns I want as dynamic ranges since the data will shrink and expand based on the estimate. I am having trouble with the correct syntax to identify columns "A" thru "M" on the last row and put a Border as a total line and turn the font to bold.
I'm totaling the columns I need to by using the "Sums Field Labor Fringe Extended Total" below for each column. However. I can't identify the range to format columns A thru M only in the last row. the "Format Last Row Field Labor" is where I left off. The Screen shot.JPG attached shows the the "Field Labor" sheets with some values. Row 11 is the Total Row in this instance. All I need to do now is figure out how to put a top thick border and turn the Font to bold.


'Sums Field Labor Fringe Extended Total
Sheets("Field Labor").Select
Dim XtndTtl As Long
XtndTtl = Range("K" & Rows.Count).End(xlUp).Row
Range("K" & XtndTtl + 1).Formula = "=Sum(K2:K" & XtndTtl & ")"

'Format Last Row Field Labor Total
Sheets("Field Labor").Select
Dim lRow As Integer
Dim lColmn As Integer
lRow = Range("A" & Rows.Count).End(xlUp).Row
lColmn = Range("A" & Columns.Count).End(xlToLeft).Column
Sheets("Field Labor").Range("A & lRow : lColmn").Borders(xlEdgeTop).Weight = xlThick
 

Attachments

  • Screen shot.JPG
    Screen shot.JPG
    109.2 KB · Views: 7
I figured out what was wrong. In the code you sent it was looking for data in Cell A. in my test worksheet Cell A currently has no data. only the cells that are totaling contain data. So it was never finding the last row.

Thank you so much for your help. This is great.
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I figured out what was wrong. In the code you sent it was looking for data in Cell A. in my test worksheet Cell A currently has no data. only the cells that are totaling contain data. So it was never finding the last row.

Thank you so much for your help. This is great.
You're welcome, and thanks for the feedback :)
 
Upvote 0

Forum statistics

Threads
1,214,829
Messages
6,121,827
Members
449,051
Latest member
excelquestion515

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