How to pass a 2-dim array to a function in the Immediate Window ...

Juggler_IN

Active Member
Joined
Nov 19, 2014
Messages
351
Office Version
  1. 2003 or older
Platform
  1. Windows
A 1-dim array is often passed in Immediate Window as, for e.g., fn_sum(Array(1,2,3)) ... how to pass a 2-dim array to fn_sum()?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
You can use Excel's notation for an array constant/literal, and pass it to the Evaluate method of the Application before passing it to your function...

VBA Code:
? fn_sum(application.evaluate("{1,2,3;4,5,6}"))


Alternatively, you can use the [ ] shortcut for the Evaluate method...

VBA Code:
? fn_sum([{1,2,3;4,5,6}])


Note that a comma delineates a column, and a semi-colon delineates a row.

Also, unlike the Array function, the indexing for the 2-dimensional array starts at 1, not 0.

Hope this helps!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,995
Messages
6,133,922
Members
449,847
Latest member
MauriceP

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top