0

I am trying to unselect empty columns from my selection and save the desired selection as a new Range object.

This is my Current Selection

and this is what I desire

Please help me out as Google search isn't helping and I am not able to find any such methods that would solve the case.

Community
  • 1
  • 1
kera_404
  • 123
  • 1
  • 12

1 Answers1

0
Selection.Cells(1).CurrentRegion.Select

Selection refers to all your selected cells. Each selection will surely contain atleast a cell. Your selection may contain 100 cells or may be 20 or may be 5. But it will surely have 1 cell in it. That code is targeting the first cell in selection and identifying the current region (Data's associated with that first cell) and selecting it.

Sixthsense
  • 1,927
  • 2
  • 16
  • 38
  • 1
    Thanks a lot, it is working now. Could you please explain what Selection.Cells(1) does (although I've seen what it does) so that I can use it as and when required. – kera_404 May 24 '16 at 07:32
  • Selection refers to all your selected cells. Each selection will surely contain atleast a cell. Your selection may contain 100 cells or may be 20 or may be 5. But it will surely have 1 cell in it. That code is targeting the first cell in selection and identifying the current region (Data's associated with that first cell) and selecting it. – Sixthsense May 24 '16 at 07:35
  • @Sixthsense It would be much better if you could add your explanation to the post and not just as a comment. – Stibu May 24 '16 at 10:03