Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    count a last cell (2000 sr 1)

    My friend...
    In the one last post you have changed my routine te find a last cell from:
    ....
    Cont = FirstFree("L0755", "A", 2)
    ....
    Public Function FirstFree(Tabella, Colonna, RigaIniziale)
    Cont = RigaIniziale
    lTest = False
    Set Check = Worksheets(Tabella).Range(Colonna + CStr(Cont))
    Do While IsEmpty(Check) <> True
    Set Check = Worksheets(Tabella).Range(Colonna + CStr(Cont))
    If IsEmpty(Check) <> True Then
    Cont = Cont + 25
    Else
    x = Cont
    Do Until lTest = True
    Set oTest = Worksheets(Tabella).Range(Colonna + CStr(x))
    If IsEmpty(oTest) = True Then
    x = x - 1
    Else
    FirstFree = x + 1
    lTest = True
    End If
    Loop
    End If
    Loop
    End Function


    in:
    ....
    Cont = FirstFree("ANOM_DETRANS", "A")
    ....
    Public Function FirstFree(Tabella, Colonna)
    FirstFree = Worksheets(Tabella).Range(Colonna & 65536).End(xlUp).Row + 1
    End Function

    in your suggestion not is necessary to set "..., 2" after the range A?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: count a last cell (2000 sr 1)

    That is correct, the modified version of FirstFree doesn't need the RigaIniziale argument. It always searches from the bottom of the Colonna up until it finds a non-blank cell, and returns the number of the row below it.
    So if you use this version of FirstFree, you must remove the third argument, and only use Tabella and Colonna.

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: count a last cell (2000 sr 1)

    Good....

Posting Permissions

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