Announcement

Collapse
No announcement yet.

Select a Range based on a value in another two cells

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Select a Range based on a value in another two cells

    Right, I need to select an area of cells on a sheet, but I need the values to be based on the values of two cells.

    Example:

    Cell A1 contains "C8"
    Cell A2 contains "C12"

    I need a piece of code that will select the area "C8:C12" using the ranges of the cells.

    If you can help thats fantastic. Thanks in advance!

  • #2
    Re: Select a Range based on a value in another two cells

    Hi

    use

    Code:
    Sub selecting()
    Dim rng As Range
    Set rng = Range(Range("A1").Value, Range("A2").Value)
    rng.Select
    End Sub
    Wigi
    Regards,

    Wigi

    Excel MVP 2011-2014

    For more Excel memes: visit http://www.wimgielis.com ==> English articles ==> Excel memes

    -- Topics without [CODE] tags or a meaningful topic title, will be neglected by me (and probably many others as well) --

    Comment


    • #3
      Re: Select a Range based on a value in another two cells

      Sorry! It's okay. I've actually found out how to do it, but for those of you who might need it some time...

      I used a concatenate function, to join them,

      Using the example from before,

      Text1 = A1
      Text2 = :
      Text3 = A2

      I placed this function in cell A3.

      Then in the code:

      Range(Range("A3)).Select

      This will select the range between two points based on two values!!

      Sorry for answering my own question!! but thanks for reading anyway.

      Comment


      • #4
        Re: Select a Range based on a value in another two cells

        Oh Sorry!!

        I didn't know I'd get a reply that quick!! Thanks very much for that. And it's a whole lot better than what I had! haha!

        Thanks very much

        Comment


        • #5
          Re: Select a Range based on a value in another two cells

          Why would you use an auxiliary function (CONCATENATE) and cell (A3) if you could do it in the macro, as I showed? You need to use the macro in any case.

          Wigi
          Regards,

          Wigi

          Excel MVP 2011-2014

          For more Excel memes: visit http://www.wimgielis.com ==> English articles ==> Excel memes

          -- Topics without [CODE] tags or a meaningful topic title, will be neglected by me (and probably many others as well) --

          Comment


          • #6
            Re: Select a Range based on a value in another two cells

            Originally posted by barno_xvi
            Oh Sorry!!

            I didn't know I'd get a reply that quick!! Thanks very much for that. And it's a whole lot better than what I had! haha!

            Thanks very much
            OK. Topic closed
            Regards,

            Wigi

            Excel MVP 2011-2014

            For more Excel memes: visit http://www.wimgielis.com ==> English articles ==> Excel memes

            -- Topics without [CODE] tags or a meaningful topic title, will be neglected by me (and probably many others as well) --

            Comment

            Working...
            X