![]() |
passing arrays between functions in VBA
Only a variant can be assigned an array - however, there usually is no need
to assign it if you pass it through the arguments of the function - but since you are giving it a new name, I assume you are assigning it. I would advise against calling your array "Array" since this is a keyword. -- Regards, Tom Ogilvy "goltinfron" wrote in message ... Ok, this may sound stupid, but, I have a program where I call in a nxm array, I will call it array0. That array is then sent to another function, and comes back, I'll call it array1. I then use try to use array1 in another function, but I get an error message. Do I need to redefine array1 as a variant before I use in another function? |
passing arrays between functions in VBA
Tom thanks, but that is not exactly what I was getting at. Maybe this will make thing clearer
function coordinates(coord ReDim a(row,column) As Varian Dim b() As Doubl a=coordinates2(coord) 'where coordinates2 is second functio b=coordinates3(a) 'where coordinates 3 is a third functio after this, i go on and do other stuff My problem is that I can get the proper answer for a, but when I try to use a in equation b, it comes up with an erro Sean |
passing arrays between functions in VBA
Pretty sketchy data (like you didn't state what the error message is),
but I assume that it is "Can't assign to array". If so, this is not a problem with a but is because b is declared as Double(). You can't assign directly to a non-Variant() array. Alan Beban goltinfron wrote: Tom thanks, but that is not exactly what I was getting at. Maybe this will make thing clearer. function coordinates(coord) ReDim a(row,column) As Variant Dim b() As Double a=coordinates2(coord) 'where coordinates2 is second function b=coordinates3(a) 'where coordinates 3 is a third function after this, i go on and do other stuff. My problem is that I can get the proper answer for a, but when I try to use a in equation b, it comes up with an error Sean |
passing arrays between functions in VBA
seems exactly what you were getting at:
Only a variant can be assigned an array -- Regards, Tom Ogilvy "goltinfron" wrote in message ... Tom thanks, but that is not exactly what I was getting at. Maybe this will make thing clearer. function coordinates(coord) ReDim a(row,column) As Variant Dim b() As Double a=coordinates2(coord) 'where coordinates2 is second function b=coordinates3(a) 'where coordinates 3 is a third function after this, i go on and do other stuff. My problem is that I can get the proper answer for a, but when I try to use a in equation b, it comes up with an error Sean |
All times are GMT +1. The time now is 09:42 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com