+ Reply to Thread
Results 1 to 4 of 4

dynamic range selection

  1. #1
    Registered User
    Join Date
    03-15-2004
    Posts
    12

    dynamic range selection

    if column b is empty but i want to select the cell in column b next to the last cell with value in column a, how can i select the empty cell in column b.


    Range("A1").Select
    Selection.End(xlDown).Select
    ??

    Thanks

  2. #2
    Ron de Bruin
    Guest

    Re: dynamic range selection

    Try this

    Sub test()
    Dim lr As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    Cells(lr, "B").Select
    End Sub


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "JohnDK" <[email protected]> wrote in message
    news:[email protected]...
    >
    > if column b is empty but i want to select the cell in column b next to
    > the last cell with value in column a, how can i select the empty cell
    > in column b.
    >
    >
    > Range("A1").Select
    > Selection.End(xlDown).Select
    > ??
    >
    > Thanks
    >
    >
    > --
    > JohnDK
    > ------------------------------------------------------------------------
    > JohnDK's Profile: http://www.excelforum.com/member.php...fo&userid=7184
    > View this thread: http://www.excelforum.com/showthread...hreadid=485700
    >




  3. #3
    Registered User
    Join Date
    03-15-2004
    Posts
    12
    Ron, thanks, i appreciate it.

    If i want to select the corresponding cell in column c as well how would i have to change the column index to include that cell.?

    Dim lr As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    Cells(lr, "B").Select

    ???cells(lr,"B:C").Select???

  4. #4
    Rowan Drummond
    Guest

    Re: dynamic range selection

    One way:

    Sub test()
    Dim lr As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    Range(Cells(lr, "B"), Cells(lr, "C")).Select
    End Sub

    Regards
    Rowan

    JohnDK wrote:
    > Ron, thanks, i appreciate it.
    >
    > If i want to select the corresponding cell in column c as well how
    > would i have to change the column index to include that cell.?
    >
    > Dim lr As Long
    > lr = Range("A" & Rows.Count).End(xlUp).Row
    > Cells(lr, "B").Select
    >
    > ???cells(lr,"B:C").Select???
    >
    >


+ 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