Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 06-26-2009, 06:29 PM
PNCD PNCD is offline
Registered User
 
Join Date: 23 Jun 2009
Location: Los Angeles
MS Office Version:Excel 2007
Posts: 25
PNCD is becoming part of the community
VBA .Transpose(.Transpose

Please Register to Remove these Ads

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.
Reply With Quote
  #2  
Old 06-26-2009, 06:35 PM
shg's Avatar
shg shg is offline
Forum Guru
 
Join Date: 20 Jun 2007
Location: The Great State of Texas
MS Office Version:2003, 2007
Posts: 18,338
shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay
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.
__________________
Entia non sunt multiplicanda sine necessitate.
Reply With Quote
  #3  
Old 06-27-2009, 06:43 AM
PNCD PNCD is offline
Registered User
 
Join Date: 23 Jun 2009
Location: Los Angeles
MS Office Version:Excel 2007
Posts: 25
PNCD is becoming part of the community
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?
Reply With Quote
  #4  
Old 06-27-2009, 07:12 AM
DonkeyOte's Avatar
DonkeyOte DonkeyOte is offline
Forum Guru
 
Join Date: 22 Oct 2008
Location: Suffolk, UK
MS Office Version:2002 & 2007
Posts: 13,574
DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute
Re: VBA .Transpose(.Transpose

Quote:
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
Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump