Consulting

Results 1 to 6 of 6

Thread: find last cell with formula

  1. #1
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    find last cell with formula

    hello
    i was trying to use johnske's article about finding the last row in a sheet containing formula using find or special cells methods.
    is there another way to find the last cell in a sheet with a formula?
    thanks
    moshe

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Why do you not want to use that method? The alternative is a long-winded check on every cell.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location
    how do you fell about:
    [VBA]
    Cells.SpecialCells(xlCellTypeFormulas, xlCellTypeLastCell).Activate

    [/VBA]
    moshe

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What do you mean? I have no feelings apart from it doesn't do what you asked originally.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location
    hello
    i found this two macros in johnske article.they both return the same result.why?
    [VBA]
    Sub Find_LastRowxlValues()
    On Error GoTo Finish
    MsgBox "Last row is row " & Cells.Find("*", _
    SearchOrder:=xlByRows, LookIn:=xlValues, _
    SearchDirection:=xlPrevious).EntireRow.row
    Exit Sub
    Finish:
    MsgBox "No values found"
    End Sub
    Sub Find_LastRowxlFormulas()
    On Error GoTo Finish
    MsgBox "Last row is-" & Cells.Find("*", _
    SearchOrder:=xlByRows, LookIn:=xlFormulas, _
    SearchDirection:=xlPrevious).EntireRow.row, vbExclamation, "last cell with a 4mula:"
    Exit Sub
    Finish:
    MsgBox "No formulas or values found - " & err.number
    End Sub

    [/VBA]
    should'nt be any difference between a cell with a constant and a cell with a formula?what is ther lookin suppose to do?
    thanks
    moshe

  6. #6
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location
    my solution:
    [VBA]
    On Error GoTo Finish
    MsgBox "Last formula row is-" & Cells.Find("=", _
    SearchOrder:=xlByRows, LookIn:=xlFormulas, _
    SearchDirection:=xlPrevious).EntireRow.row, vbExclamation, "last cell with a 4mula:"
    Exit Sub
    Finish:
    MsgBox "No formulas or values found - " & err.number, vbCritical, "error"

    [/VBA]
    moshe

Posting Permissions

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