Note that there are some explanatory texts on larger screens.

plurals
  1. POExcel VBA: Unlimited Range Inputs With Versatility (?)
    primarykey
    data
    text
    <p>Could someone help me create a function that will handle an unlimited number of diverse ranges? I have tried "Paramarray variables() as Variant" and "variable as Range" in my arguments list but neither of them provide the versatility that I am looking for. </p> <p>The key is that I want my function to be able to simultaneously handle things like "MyFunc(A1:A10, B1)" or "MyFunc(A1, B1:10, C11)". The problem I'm finding is that "ParamArray" can only handle comma separated inputs while "variable as Range" can only handle non-comma separated inputs. </p> <p>Basically, I want to have the same functionality that the SUM() function has. Where SUM can handle an infinite (sort of) number of inputs regardless if they are separated by commas or are in a range. </p> <p>As requested, here is my code:</p> <pre><code>Function COMMA_DELIMITER(inputs as Range) ' this function basically concatenates a consecutive set of cells and places commas between values For Each j in Inputs stringy = stringy &amp; j.value &amp; chr(44) Next stringy = Left(stringy, Len(stringy) - 1) COMMA_DELIMITER = stringy End Function </code></pre> <p>or</p> <pre><code>Function COMMA_DELIMITER_A(ParamArray others()) 'this is the same function, only the cells don't have to be consecutive For i = 1 to UBound(others) + 1 stringy = stringy &amp; others(i-1) &amp; chr(44) Next COMMA_DELIMIERTER_A = Left(stringy, Len(stringy) - 1) End Function </code></pre> <p>I pretty much want to create a function that has the flexibility to handle both consecutive cells and/or non-consecutive cells. The inputs would look like this, "=MyFunc(A1, B1:B10, C11, D12:D44)".</p> <p>Could someone help me create a function that can handle something like this, "MyFunc(A1, B1:B10, C11, D12:D44)"?</p> <p>Thanks,</p> <p>Elias</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload