Search notes:

Test for function excelRangeSubtract of the VBA module ExcelSheet

The following VBA module tests the function excelRangeSubtract of the helper module ExcelRange.
option explicit

sub main() ' {

    test_subtraction range(cells( 2,2), cells(7 ,6)), range(cells(3,3), cells(6,5))
    test_subtraction range(cells(12,2), cells(17,6)), range(rows(12), rows(13))
    test_subtraction range(cells(22,2), cells(27,6)), range(cells(23,3), cells(28,7))

    test_subtraction excel.application.union(range( cells(30,2), cells(31,3) ) ,    _
                                             range( cells(33,2), cells(34,3) ) ,    _
                                             range( cells(30,6), cells(31,7) ) ,    _
                                             range( cells(33,6), cells(34,7) ) ) ,  _
                                             range( cells(31,3), cells(33,6))


end sub ' }


sub test_subtraction(rng_1 as range, rng_2 as range) ' {

    rng_1.borderAround xlContinuous, xlMedium, color := rgb(240, 10,  40)
    rng_2.borderAround xlContinuous, xlMedium, color := rgb( 30, 10, 200)

    dim rngRes as range
    set rngRes = excelRangeSubtract(rng_1, rng_2)

    rngRes.interior.color = rgb(255, 240, 190)

    debug.print "rngRes.areas.count = " & rngRes.areas.count

end sub ' }
Github repository VBAModules, path: /_test/Office/xls-subtractRange.vb
<job>
<script language="VBScript" src="../VBS-MS-Office-App-Creator/create-MS-Office-app.vbs" />
<script language="VBScript">

   option explicit

   dim app
   dim xls
   set xls = createOfficeApp("excel", currentDir() & "created.xlsm")
   if xls is nothing then ' {
      wscript.echo "Could not create excel worksheet."
      wscript.quit -1
   end if ' }

   set app = xls.application

   insertModule app, currentDir() & "../../Office/ExcelRange.vb"   , "ExcelRange"   , 1
   insertModule app, currentDir() & "xls-subtractRange.vb"         , "func"         , 1

   app.run "main"

   xls.save

   createObject("WScript.Shell").appActivate(app.caption)

</script> </job>
Github repository VBAModules, path: /_test/Office/xls-subtractRange.wsf

Index