+ Reply to Thread
Results 1 to 7 of 7

End(xldown) not always going to last cell?

  1. #1
    Duncan
    Guest

    End(xldown) not always going to last cell?

    Hi all, Im using Range("f1").End(xlDown).Offset(1, 0).Select to get to
    the next empty cell downwards in a column, It doesnt always work?
    sometimes it selects the same cell over and over (im using this in
    various instances).

    is it something to do with the cell containing a number? also if the
    collumn is blank then it crashes out, i have to have a line of 1s above
    the column to make the code work.

    is there a better way?


    Duncan


  2. #2
    Norman Jones
    Guest

    Re: End(xldown) not always going to last cell?

    Hi Duncan

    > is there a better way?


    Try:

    Dim rng as Range

    Set rng = Cells(Rows.Count, "A").End(xlUp)(2)

    Additionally, it is rarely necessary to make selections: it is usually more
    efficient to manipulate the range object.


    ---
    Regards,
    Norman


    "Duncan" <[email protected]> wrote in message
    news:[email protected]...
    > Hi all, Im using Range("f1").End(xlDown).Offset(1, 0).Select to get to
    > the next empty cell downwards in a column, It doesnt always work?
    > sometimes it selects the same cell over and over (im using this in
    > various instances).
    >
    > is it something to do with the cell containing a number? also if the
    > collumn is blank then it crashes out, i have to have a line of 1s above
    > the column to make the code work.
    >
    > is there a better way?
    >
    >
    > Duncan
    >




  3. #3
    Ivan Raiminius
    Guest

    Re: End(xldown) not always going to last cell?

    Hi Duncan,

    you can use:

    range("F" & application.rows.count).end(xlup).offset(1,0).select

    If I understood your question correctly.

    Regards,
    Ivan


  4. #4
    Duncan
    Guest

    Re: End(xldown) not always going to last cell?

    Brill, thats a lot better than before, also, I have changed it do
    rng2.Value instead of selecting it and then doing activecell.value. I
    think that will be faster.

    Just another question.....im using rng2.Value = Now() but I could
    really do with just the time and not the date, is that a command?

    Duncan


  5. #5
    Norman Jones
    Guest

    Re: End(xldown) not always going to last cell?

    Hi Duncan

    > Just another question.....im using rng2.Value = Now() but I could
    > really do with just the time and not the date, is that a command?



    Try:

    rng2.Value = Time()

    ---
    Regards,
    Norman



  6. #6
    Duncan
    Guest

    Re: End(xldown) not always going to last cell?

    Many thanks, it appears I am as thick as I thought I was....i have used
    time() before.........

    Many thanks all

    Duncan


  7. #7
    Gary''s Student
    Guest

    Re: End(xldown) not always going to last cell?

    To set the time:

    Sub asdf()
    Selection.NumberFormat = "[$-409]h:mm:ss AM/PM;@"
    Selection.Value = Now() - Int(Now())
    End Sub
    --
    Gary's Student


    "Duncan" wrote:

    > Brill, thats a lot better than before, also, I have changed it do
    > rng2.Value instead of selecting it and then doing activecell.value. I
    > think that will be faster.
    >
    > Just another question.....im using rng2.Value = Now() but I could
    > really do with just the time and not the date, is that a command?
    >
    > Duncan
    >
    >


+ 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