+ Reply to Thread
Results 1 to 5 of 5

Dynamic Variable in Split function Expression

  1. #1
    Registered User
    Join Date
    06-19-2013
    Location
    Sheffield
    MS-Off Ver
    Excel 2013
    Posts
    86

    Dynamic Variable in Split function Expression

    Hello,

    does somebody knows if it is possible to include a dynamic variable in the Split function Expression?
    I'll make an example.
    I have two strings:
    C1 = "A_B_C_D_"
    C2 = "1_2_3_4_"

    Instead of using twice the Split function like:
    myArray1 = Split(C1, "_")
    myArray2 = Split(C2, "_")

    I would like to create a loop like:
    For j = 1 to 2
    For i = 1 to 4
    myString = "C" & j
    myArray(j, i) = Split(myString, "_")
    Next

    This would allow me to fill a bidimensional array within a loop.

    I've tried to do it as simply shown in the example but the Split function read C1 as a string instead of reading its value (C1 = "A_B_C_D_").

    Thank you
    Last edited by BrianAll; 07-02-2013 at 10:01 PM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Dynamic Variable in Split function Expression

    Brian,
    Please use code tags as per forum's rule.
    Yes you can. All you need to is to loop through either the range or an array.
    The first code, loops through 4 columns for each row and display the split result in to next empty row in column C. The second code first loads the data in to array and loop through the array and load back the range in to array. This is not complete code, just to give a headway.
    Please Login or Register  to view this content.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,573

    Re: Dynamic Variable in Split function Expression

    Please Login or Register  to view this content.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Dynamic Variable in Split function Expression

    for instance
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Registered User
    Join Date
    06-19-2013
    Location
    Sheffield
    MS-Off Ver
    Excel 2013
    Posts
    86

    Re: Dynamic Variable in Split function Expression

    Hello,

    since I don't have to deal with Ranges but only with strings and arrays, the last solution was the most appropriate.
    Joseph, it's exactly what I was searching for.

    Thank you all

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.6.0 RC 1