+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    06-23-2009
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    25

    VBA .Transpose(.Transpose

    I have been looking at various VBA code snippets for something I am trying to do.
    I am taking a user-defined range and then passing it to a function which will apply a calculation to all the values in that range (say n ^ 2).
    What I see in the snippets is often code that looks like this:
    y = .Transpose(.Transpose(y))
    Where y is the data range passed to the calculation function.
    .Transpose would convert the columnar range to a row array (yes?). But why yet another .Transpose?
    My only guess is that this takes a range of data (passed to this calculation function) to make it an array of data with the same dimensionality as the original.
    Is that correct? What does .Transpose have to do with making ranges into arrays in VBA?
    Thank you for your help.

  2. #2
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,126

    Re: VBA .Transpose(.Transpose

    Transposing twice converts the data from a 2D array (the uniform result in a variant receiving data from a multi-cell range) to a 1D array if the range is a row or column vector.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    06-23-2009
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: VBA .Transpose(.Transpose

    Thank you.
    What is the result of a single transpose and how does one convert a two-dimensional range into a two dimensional array?

  4. #4
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: VBA .Transpose(.Transpose

    I am taking a user-defined range and then passing it to a function which will apply a calculation to all the values in that range (say n ^ 2)
    Possibly use Evaluate ?

    Code:
    Selection.Value = Evaluate("IF(ROW(" & Selection.Address & ")*ISNUMBER(" & Selection.Address & ")," & Selection.Address & "^2,TEXT(" & Selection.Address & ",""?""))")
    above is based on contiguous range which may include both numerics & non-numerics, for non-contiguous range you would need to iterate the range areas

Thread Information

Users Browsing this Thread

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

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.2.0