Search notes:

Office Object Model: Excel - Application / set operations

The application object provides the two functions union and intersect with which «set operations» can be performed with ranges.

union

option explicit

public sub main()

    dim range_1      as range
    dim range_2      as range

    dim range_result as range

    set range_1 = activeSheet.range("d3:f9")
    set range_2 = activeSheet.range("b6:h7")

    set range_result = union (range_1, range_2)

    range_result.interior.color = RGB(255, 127 , 30)

    activeWorkbook.saved = true

end sub
Github repository about-MS-Office-object-model, path: /Excel/Application/union.bas
See also the union operator in formulas.

intersect

option explicit

public sub main()

    dim range_1      as range
    dim range_2      as range

    dim range_result as range

    set range_1      = activeSheet.range("d3:f9")
    set range_2      = activeSheet.range("b6:h7")
    set range_result = intersect (range_1, range_2)

    range_1.value="Range 1"
    range_2.value="Range 2"

    range_result.value="Intersection"

    activeWorkbook.saved = true

end sub
Github repository about-MS-Office-object-model, path: /Excel/Application/intersect.bas
See also the intersect operator in formulas.

TODO

application.range seems to correspond to the colon operator.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1758194178, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/Office/Excel/Object-Model/Application/set-operations(100): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78