How to create a range from two ranges in VBA?

前端 未结 5 742
北恋
北恋 2020-11-29 09:15

I have two ranges, each containing a single cell (for example \"A1\" and \"C3\").

How do I get a new range containing all the cells between these two (\"A1:C3\")?

5条回答
  •  一向
    一向 (楼主)
    2020-11-29 09:46

    It´s also possible something like:

        Dim newRange as Range
        Set newRange = Range("A1:A4,A7:A9,C1:D9")  'Three different regions grouped
        'or
        Set newRange = Range("A1:A4,A7:A9,C1:D9, D10:D11")  'Four different regions grouped.
        'or
        Set newRange = Range("A1:A4,A7:A9,C1:D9, D10:D11, ...")  'N different regions grouped.
    

提交回复
热议问题