+ Reply to Thread
Results 1 to 8 of 8

Use the TRANSPOSE() function to transpose a range as an input to the UDF

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Use the TRANSPOSE() function to transpose a range as an input to the UDF

    Dear Sir,

    I'm very curious about using output from the TRANSPOSE() function as an input to the UDF function. For the first UDF below, it will work if you specify it as: =MaxDrawDown(TRANSPOSE(A11:G11)) , confirmed Ctrl+Shift+Enter. But for the second UDF, it will be an #VALUE! error if specified as =DivGrowth(TRANSPOSE(A1:A11)), confirmed with Ctrl+Shift+Enter.

    Can I ask why the TRANSPOSE() worked for the first UDF, but not the second?



    Please Login or Register  to view this content.
    Last edited by alice2011; 03-09-2015 at 08:51 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Use the TRANSPOSE() function to transpose a range as an input to the UDF

    DivGrowth will fail immediately because, I assume, TRANSPOSE(A1:A11) doesn't return a range.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: Use the TRANSPOSE() function to transpose a range as an input to the UDF

    Hi, can I ask why it worked for the first UDF?

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Use the TRANSPOSE() function to transpose a range as an input to the UDF

    Hi alice,

    I'm wondering about returning arrays from a function and found some hints at:
    http://www.cpearson.com/excel/return...ysfromvba.aspx

    But more fundamentally he talks about problems with UDF at:
    http://www.cpearson.com/excel/Writin...ionsInVBA.aspx

    I hope the above two links will help you figure out your own question.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Use the TRANSPOSE() function to transpose a range as an input to the UDF

    The first UDF takes a variant as an argument and as far as I can see from the code it's a variant array.

    PS If you step through the DivGrowth formula on the worksheet using Formulas>Evaluate Formula you'll see what TRANSPOSE returns.

  6. #6
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: Use the TRANSPOSE() function to transpose a range as an input to the UDF

    Hi Norie, i'm totally confused Very sorry.

    So variant can be transposed? But range cannot be transposed? I thought in Excel all ranges can be transposed too.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Use the TRANSPOSE() function to transpose a range as an input to the UDF

    No.

    DivGrowth expects a range as an argument, TRANSPOSE(A1:A11) doesn't return a range it returns an array.

    If you try calling DivGrowth in code like this you'll get an 'Object required' error.
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: Use the TRANSPOSE() function to transpose a range as an input to the UDF

    What a great piece of knowledge! Really learned. thank you, Norie. It has been helpful.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. transpose column to a range calculate and transpose to new table loop
    By moshro1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-02-2015, 10:52 AM
  2. [SOLVED] Transpose: How can I copy a list and transpose it but leaving 3 cells in between each item
    By cocolete in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-11-2012, 10:01 AM
  3. Input 6 values, transpose to bottom of a column
    By bluerog in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-28-2010, 05:34 PM
  4. Passing Range using TRanspose causes Function to Fail
    By Bazman2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2009, 07:38 AM
  5. Replies: 2
    Last Post: 02-19-2007, 04:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1