VBA: rename a variable

  • Thread starter Thread starter qwerqtzui
  • Start date Start date
Q

qwerqtzui

hi folks,

my problem is the following: i want to rename a variable with a name
that could be entered as a parameter to the subroutine, a la:

sub addvariables(var1, var2, NameOfVar3)
var3 = var1 + var2
rename var3 as NameOfVar3 'pseudo-code!!!
sub end

how can i "rename" var3 into "NameOfVar3". i need the new name for
further referencing.

thanx in advance,
felix
 
Hi Felix,

What is it that you are trying to do? Maybe we can come up with a different
solution. I've never encountered a situation where I had to rename a
variable.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
Hi Jake,

I want to program a simple matrix addition that I can easily call
within vba. It should return the resulting matrix. Can you help me with
that?

Thanx,

Felix
 
Are the matrices in question in Excel ranges, or are they in memory (as
arrays)? If they are in ranges, you can do something like this:

1) Select the range that you would like the resulting matrix to be placed in
(must be same size as matrices to be added).

2) Type =, then select your first matrix, then type +, then select you
second matrix, and so on.

3) Use Ctrl+Shift+Enter to enter the formula (that lets Excel know it's an
array formula).

That should fill the selected range with the sum of the other matrices.

If the matrices are in memory, you'll have to loop through the elements of
each matrix and add them up. I think a search of groups.google.com would
assist you with this.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
Back
Top