+ Reply to Thread
Results 1 to 11 of 11

Splitting Semester and Year into 2 columns (Fall '10)

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Splitting Semester and Year into 2 columns (Fall '10)

    I have a column of semester and year values such as this: "Fall '10", "Spring '11".......etc

    I am trying to use the following code to split the semester and year into arrays but i keep getting a runtime error.

    Here is the code:

    Please Login or Register  to view this content.
    Last edited by welchs101; 01-26-2012 at 09:37 AM.

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Splitting Semester and Year into 2 columns (Fall '10)

    What is in alphacol(enroll_col)?

  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Splitting Semester and Year into 2 columns (Fall '10)

    in the enroll col are the entries like "Fall '10", "Spring '11", etc

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Splitting Semester and Year into 2 columns (Fall '10)

    Please post a sample workbook.....

    I think you have to add a column after each column you want to split.
    After having done this you can use texttocolumns.



  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Splitting Semester and Year into 2 columns (Fall '10)

    i will post an example but first i have a question:

    The run-time error occurs at the 2nd line of code not the first. The first works fine........the only difference between the first row and the 2nd is the (0) and the (1) at the end of each line.

    My understanding of the (0) and (1) is that these identify which element of the array created by the split function that you want. The first line seems to be working as expected but not the 2nd. Am i doing this wrong? I will post an example workbook as well.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Splitting Semester and Year into 2 columns (Fall '10)

    this suffices:
    Please Login or Register  to view this content.
    PS. You could have used the macrorecorder yourself.....

    if you want to use the other method

    Please Login or Register  to view this content.
    Last edited by snb; 01-17-2012 at 09:58 AM.

  7. #7
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Splitting Semester and Year into 2 columns (Fall '10)

    thanks SNB......

    I still wonder by

    this works
    Please Login or Register  to view this content.


    but this does not
    Please Login or Register  to view this content.

    does not make sense to me. Thanks for the different solns.

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Splitting Semester and Year into 2 columns (Fall '10)

    You didn't assign any range/values to that array; you only redimmed it.

  9. #9
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Splitting Semester and Year into 2 columns (Fall '10)

    but why did the first array work one work........i did not assign anything to it.....i dont think

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Splitting Semester and Year into 2 columns (Fall '10)

    So what does this mean ?

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Splitting Semester and Year into 2 columns (Fall '10)

    hi snb,

    recall the following:

    Please Login or Register  to view this content.
    If i leave off

    Please Login or Register  to view this content.
    the code runs fine. It stores the values into enroll_semester_array correctly. But when it gets to the 2nd one
    namely the assignment for enroll_year_array i get a run time error. Your code gets around this because it works. But i still dont know why this 2nd assignment causes a run time error and the first one does not.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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