Copy multiple ranges with VBA

后端 未结 2 1090
耶瑟儿~
耶瑟儿~ 2020-12-21 17:31

I am trying to copy multiple ranges using Excel VBA. I understand that in order to select multiple ranges, syntax similar to that below is used:

Range(\"A1:B         


        
2条回答
  •  遥遥无期
    2020-12-21 18:05

    Use the "Union" method.

    Dim range1 as Range, range2 as Range, multipleRangeAs Range    
    Set range1 = Sheets("Sheet1").Range("A1:B4000")    
    Set range2 = Sheets("Sheet1").Range("F1:F4000")    
    Set multipleRange= Union(range1, range2)
    

    Then you can mess around with mutipleRange as per normal.

提交回复
热议问题