Results 1 to 3 of 3

Thread: VBA + Excel

  1. #1

    Thread Starter
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249

    Talking 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."

  2. #2
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    ActiveSheet.UsedRange.Select

    Thats a start. i`m sure you can count the rows and columns.


    Seahag

  3. #3
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Omaha, NE
    Posts
    270
    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:
    1. Dim strColRow() As String
    2.     Dim strColumn As String
    3.     Dim lngRow As Long
    4.  
    5.     'Next statement is the same as doing an End-Home key combination
    6.     ActiveCell.SpecialCells(xlLastCell).Select
    7.     'Splits out the address parts (col,row) into an array
    8.     strColRow = Split(ActiveCell.Address, "$")
    9.     'Since address starts with '$', first element in strColRow array is null
    10.     strColumn = strColRow(1)
    11.     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
  •  



Click Here to Expand Forum to Full Width