|
-
Jul 2nd, 2002, 08:12 AM
#1
Thread Starter
Addicted Member
VBA + Excel
How would I Detect the last column and the last row used in a worksheet? thanks!
"There are two ways to write error-free programs. Only the third one works."
"Real programmers don't comment their code. If it was hard to write, it should be hard to understand."
-
Jul 2nd, 2002, 08:28 AM
#2
Fanatic Member
ActiveSheet.UsedRange.Select
Thats a start. i`m sure you can count the rows and columns.
Seahag
-
Jul 2nd, 2002, 10:14 AM
#3
Hyperactive Member
You might try this. It gives you the column in letter form (ie. A, B, C, ...) instead of numeric form (1, 2, 3, ...) & the row number.
VB Code:
Dim strColRow() As String
Dim strColumn As String
Dim lngRow As Long
'Next statement is the same as doing an End-Home key combination
ActiveCell.SpecialCells(xlLastCell).Select
'Splits out the address parts (col,row) into an array
strColRow = Split(ActiveCell.Address, "$")
'Since address starts with '$', first element in strColRow array is null
strColumn = strColRow(1)
lngRow = strColRow(2)
Hope this helps.
Nate
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|