Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default FUNCTION TO COPY STRING ARRAY !!

Hi -

I am looking for a vba function, copyArray()of type String, that will
take in one String array, and produce a copy of the input.

Specs:
(1)The function should be able to take in either 1D or 2D string array,
and produce its copy.
(2)If the input is just "" or vbNullString, the output should be the
same as well.

Any help will be appreciated!
Thanks
Jay Dean


*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default FUNCTION TO COPY STRING ARRAY !!

Sub test()

Dim i As Long
Dim arrString1(0 To 10) As String
Dim arrString2() As String

For i = 0 To 10
arrString1(i) = Chr(i + 65)
Next i

'copy the array
arrString2 = arrString1

For i = 0 To 10
MsgBox arrString2(i)
Next i

End Sub


RBS


"jay dean" wrote in message
...
Hi -

I am looking for a vba function, copyArray()of type String, that will
take in one String array, and produce a copy of the input.

Specs:
(1)The function should be able to take in either 1D or 2D string array,
and produce its copy.
(2)If the input is just "" or vbNullString, the output should be the
same as well.

Any help will be appreciated!
Thanks
Jay Dean


*** Sent via Developersdex http://www.developersdex.com ***


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default FUNCTION TO COPY STRING ARRAY !!

On Sun, 19 Jul 2009 14:05:48 -0700, jay dean wrote:

Hi -

I am looking for a vba function, copyArray()of type String, that will
take in one String array, and produce a copy of the input.

Specs:
(1)The function should be able to take in either 1D or 2D string array,
and produce its copy.
(2)If the input is just "" or vbNullString, the output should be the
same as well.

Any help will be appreciated!
Thanks
Jay Dean


*** Sent via Developersdex http://www.developersdex.com ***


If your function argument is a variant, and it's output is a variant, you can
just set the input equal to the output.

e.g.:

==========================
Function CopyStringArray(s1)
CopyStringArray = s1
End Function
=========================

If you need to, you can cycle through each element of the array to ensure it is
of type String. You can also test to see if it is an array.
--ron
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default FUNCTION TO COPY STRING ARRAY !!

Thanks, Ron! I think using the variant datatype even though uses more
memory would suffice for this purpose. I am trying to keep loops to a
minimum so your approach works well.

Jay Dean



*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default FUNCTION TO COPY STRING ARRAY !!

On Sun, 19 Jul 2009 19:55:53 -0700, jay dean wrote:

Thanks, Ron! I think using the variant datatype even though uses more
memory would suffice for this purpose. I am trying to keep loops to a
minimum so your approach works well.

Jay Dean



*** Sent via Developersdex http://www.developersdex.com ***



Glad to help. Thanks for the feedback.
--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems Loading Large String Array into Array variable ExcelMonkey Excel Programming 6 May 6th 09 11:12 PM
Using a 2 dimensional string array variable like a lookup function Conan Kelly Excel Programming 5 December 3rd 07 03:03 PM
Function (array argument, range argument, string argument) vba Witek[_2_] Excel Programming 3 April 24th 05 03:12 PM
Passing a String in Array to Range as String [email protected] Excel Programming 2 September 1st 04 01:13 AM
Return string array from function in excel 97 Stelio Excel Programming 1 December 4th 03 11:40 AM


All times are GMT +1. The time now is 12:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"