I've found dozens of almost answers, but am too ignorant to take the pieces to do what I want. I need to find the last row and the last column and name the range.
Many, many postings show getting the last row, or the last column, but not how to use both in the expression. And cautions against UsedRange . . .
I use this often,
but have no idea how to use both the LastRow and LastCol . . .
All of Row 1 has headers. No blank/null cells.
All of Column "A" has entries. Again, no blank/null cells.
No formatting
No skipped rows or columns
My "almost there" code, I know I'm not using the LastRow and LastCol properly, but no idea how they should be used.
As always,
TIA
Ron
Many, many postings show getting the last row, or the last column, but not how to use both in the expression. And cautions against UsedRange . . .
I use this often,
Code:
Selection.AutoFill Destination:=Range("E2:E" & LastRow)
All of Row 1 has headers. No blank/null cells.
All of Column "A" has entries. Again, no blank/null cells.
No formatting
No skipped rows or columns
My "almost there" code, I know I'm not using the LastRow and LastCol properly, but no idea how they should be used.
Code:
Sub LRowLColRng()
Dim thiswksht As Activesheet
Dim LastRow As Long
Dim LastCol As Integer
Dim rng As Range
Set thiswksht = ActiveSheet
With thiswksht
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
End With
rng = (LastRow & LastCol) 'broken . . .
rng.Select
Selection.Name = "tbl_P"
End Sub
As always,
TIA
Ron