1

I have an Array say A=(11,23,32,44,56,88,55,14,78,79) And B=(44,56,88,55,14) .Now using VBScript can I perform Set operation MINUS to get an other output say C=(11,23,32,78,79)?

Array A and B can be considered also two Excel columns.

Don't want to use any Looping technique.

Please help

Thanks,

Community
  • 1
  • 1
arun_roy
  • 601
  • 6
  • 16
  • 42

3 Answers3

4

No, vbs or vba cannot directly do a minus operation on two array ( no build-in function ) You must use loops and here is a good reference for array operations in vba http://www.cpearson.com/excel/vbaarrays.htm

Community
  • 1
  • 1
Larry
  • 2,764
  • 2
  • 25
  • 36
2

Perhaps it's not a surprise that Dictionaries are the VBScript tool to implement (fake?) sets and operations on them. See this Set demo.

BTW: If you have to deal with more than one thingy, you'll have to loop or ask someone else to loop for you. Insisting on "no loop, please" makes no sense. If 'it works', you may optimize by replacing multiple loops (n x m .. x z) by lookup tables or pre-computations, but you won't understand the problem, if you don't think of loopings.

Community
  • 1
  • 1
Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96
  • any good idea from you on the below post? http://stackoverflow.com/questions/13927207/subtraction-between-to-excel-column-using-vbscript/13928903#13928903 – arun_roy Dec 18 '12 at 12:40
0

You can do that in Excel vba if u have named ranges Acol Bcol

Range("C3:C10").FormulaArray = "=Acol-Bcol"
user1981275
  • 13,002
  • 8
  • 72
  • 101
soco
  • 1