+ Reply to Thread
Results 1 to 5 of 5

Find last nonblank cell in column

  1. #1
    Pink Panther
    Guest

    Find last nonblank cell in column

    I have a small problem and don't know how to solve it...
    Let's say I have range A1:A20 filled with some values and want to add a new
    value in A21 but A19:A20 is hidden.
    I tried range("A1.end(xlDown).offset(1,0)="hallo", but the result of this
    is that I fill range("A19") with "hallo" instead of range("A21")

    How can I solve this little problem without unhiding those rows???

    Thanks in advance,

    Paul Bleijlevens



  2. #2
    Forum Contributor
    Join Date
    03-03-2005
    Posts
    315
    Pink, this will solve it:

    Sub n()
    Cells(Application.CountA(Range("a:a")) + 1, "a") = "halo"
    End Sub

  3. #3
    Bob Phillips
    Guest

    Re: Find last nonblank cell in column

    Paul,

    Try this

    Range("A" & LastRow(Range("A1:A20")) + 1) = "hallo"

    Function LastRow(rng As Range)
    On Error Resume Next
    LastRow = 1
    With rng
    LastRow = .Find("*", .Cells(1), xlFormulas, _
    xlWhole, xlByRows, xlPrevious).Row
    End With
    End Function


    --
    HTH

    Bob Phillips

    "Pink Panther" <[email protected]> wrote in message
    news:[email protected]...
    > I have a small problem and don't know how to solve it...
    > Let's say I have range A1:A20 filled with some values and want to add a

    new
    > value in A21 but A19:A20 is hidden.
    > I tried range("A1.end(xlDown).offset(1,0)="hallo", but the result of

    this
    > is that I fill range("A19") with "hallo" instead of range("A21")
    >
    > How can I solve this little problem without unhiding those rows???
    >
    > Thanks in advance,
    >
    > Paul Bleijlevens
    >
    >




  4. #4
    Bob Phillips
    Guest

    Re: Find last nonblank cell in column


    "davidm" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Pink, this will solve it:
    >
    > Sub n()
    > Cells(Application.CountA(Range("a:a")) + 1, "a") = "halo"
    > End Sub


    Not if the range includes some blank entries.



  5. #5
    Pink Panther
    Guest

    Re: Find last nonblank cell in column

    Thanks, this would do the job....


    "Bob Phillips" <[email protected]> wrote in message
    news:[email protected]...
    >
    > "davidm" <[email protected]> wrote in
    > message news:[email protected]...
    >>
    >> Pink, this will solve it:
    >>
    >> Sub n()
    >> Cells(Application.CountA(Range("a:a")) + 1, "a") = "halo"
    >> End Sub

    >
    > Not if the range includes some blank entries.
    >
    >




+ 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