none
Setting range for 1 column to end of not contiguous data RRS feed

  • Question

  • Hi,

    I am trying to set a range but am getting an unexpected result.

    here is my code

                Dim rngItms1 As Range
                Set rngItms1 = .Range(Cells(3, 7), .Range("c65536").End(xlUp))
                'Set rngItms1 = .Range("g3", Range("c65536").End(xlUp))
                rngItms1.Select

    The code sets the range to C3 to G92 but the result I am looking for is G3 to G92

    I can not see why it is selecting columns C-F

    using "g3" gives the same results.

    Thanks for any advice,

    Doug

    Wednesday, July 20, 2016 11:55 PM

Answers

  • Range("c65536").End(xlUp) is in column C, not in column G. So either use Range("G65536").End(xlUp)), or if you need to look at column C for the last used row, use Range("C65536").End(xlUp).Offset(0, 4)

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Dactech1 Thursday, July 21, 2016 3:33 AM
    Thursday, July 21, 2016 2:45 AM

All replies

  • Range("c65536").End(xlUp) is in column C, not in column G. So either use Range("G65536").End(xlUp)), or if you need to look at column C for the last used row, use Range("C65536").End(xlUp).Offset(0, 4)

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Dactech1 Thursday, July 21, 2016 3:33 AM
    Thursday, July 21, 2016 2:45 AM
  • Thanks Hans,

    Thursday, July 21, 2016 3:34 AM