+ Reply to Thread
Results 1 to 5 of 5

max row and max col

  1. #1
    Shinya Koizumi
    Guest

    max row and max col

    How to find out the maximum row and col in the current worksheet without
    going to the actual cell?

    I know if i actually go to the last cell i can find out.

    Selection.End(xlToRight).Select





  2. #2
    Bob Phillips
    Guest

    Re: max row and max col

    Selection.End(xlDown).Row

    and

    Selection.End(xlToRight).Column

    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "Shinya Koizumi" <[email protected]> wrote in message
    news:#[email protected]...
    > How to find out the maximum row and col in the current worksheet without
    > going to the actual cell?
    >
    > I know if i actually go to the last cell i can find out.
    >
    > Selection.End(xlToRight).Select
    >
    >
    >
    >




  3. #3
    Jim Thomlinson
    Guest

    RE: max row and max col

    This should work for you. It finds the right most populated column and bottom
    most populeted row.

    Public Sub LastCell(Optional ByVal wks As Worksheet)
    Dim lngLastRow As Long
    Dim intLastColumn As Integer

    If wks Is Nothing Then Set wks = ActiveSheet
    On Error Resume Next
    lngLastRow = wks.Cells.Find(What:="*", _
    After:=wks.Range("A1"), _
    Lookat:=xlPart, _
    LookIn:=xlFormulas, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlPrevious, _
    MatchCase:=False).Row
    intLastColumn = wks.Cells.Find(What:="*", _
    After:=wks.Range("A1"), _
    Lookat:=xlPart, _
    LookIn:=xlFormulas, _
    SearchOrder:=xlByColumns, _
    SearchDirection:=xlPrevious, _
    MatchCase:=False).Column
    On Error GoTo 0
    If lngLastRow = 0 Then
    lngLastRow = 1
    intLastColumn = 1
    End If
    End Sub

    --
    HTH...

    Jim Thomlinson


    "Shinya Koizumi" wrote:

    > How to find out the maximum row and col in the current worksheet without
    > going to the actual cell?
    >
    > I know if i actually go to the last cell i can find out.
    >
    > Selection.End(xlToRight).Select
    >
    >
    >
    >
    >


  4. #4
    Shinya Koizumi
    Guest

    Re: max row and max col

    Dim app as Excel.Application

    app.ActiveSheet.Rows.Count

    worked for me

    thanks

    Shinya



  5. #5
    Bob Phillips
    Guest

    Re: max row and max col

    Doesn't that just return 65536 every time?

    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "Shinya Koizumi" <[email protected]> wrote in message
    news:[email protected]...
    > Dim app as Excel.Application
    >
    > app.ActiveSheet.Rows.Count
    >
    > worked for me
    >
    > thanks
    >
    > Shinya
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1