Question : creating Excel macro to manipulate date usnig VB

Experts,

I have an excel spreadsheet with the following data:

         A          B            C
1    Smith      John        5
2    Campbell Sara       4
3    Reese     Jim         4
4    Soza       Haley     3

I need a macro to manipluate the data to the following after the macro is run:

         A                                                          B            C
1    Smith,John,jsmith,welcome,5,6
2    Campbell,Sara,scampbell,welcome,4,5
3    Reese,Jim,jreese,welcome,4,5
4    Soza,Haley,hsoza,welcome,3,4

The import file format for students is:
LastName,FirstName,Username,Password,Grade,GroupID with each student on a separate line.
Following is the mapping for the grade level groups. I need an if statement to insert the appropriate group ID based on the grade level. For example, above Haley is in the 3rd grade and hence will belong to the 4th group. The macro needs to replace items in cell A, B, C with the comma delimited line in column A only. I would really like to see how this is accomplished so I may try on other different variations. Kind of a rush on this code so offering 500 pts.
Group one – Kindergarten
Group 2 – 1st grade
Group 3- 2nd grade
Group 4 – 3rd grade
Group 5 – 4th grade
Group 6 – 5th grade
Group 7 – 6th grade

Thanks!

Shogun5

Answer : creating Excel macro to manipulate date usnig VB

Small modification for correct username.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
Sub Reorganizedata()
Dim mArray As Variant
Dim wArray As Variant
Dim mS As Worksheet
Dim lRow As Long
Set mS = ThisWorkbook.Worksheets("Sheet1")
lRow = mS.UsedRange.SpecialCells(xlCellTypeLastCell).Row
mArray = mS.Range("A1:C" & lRow)
wArray = mS.Range("D1:D" & lRow)
For i = 1 To lRow
    If mArray(i, 3) = "Kindergarten" Then
        wArray(i, 1) = mArray(i, 1) & "," & mArray(i, 2) & "," & LCase(Left(mArray(i, 2), 1)) & LCase(mArray(i, 1)) & "," & "welcome" & "," & mArray(i, 3) & "," & 1
    Else
        wArray(i, 1) = mArray(i, 1) & "," & mArray(i, 2) & "," & LCase(Left(mArray(i, 2), 1)) & LCase(mArray(i, 1)) & "," & "welcome" & "," & mArray(i, 3) & "," & mArray(i, 3) + 1
    End If
Next i
mS.Range("A1:C" & lRow).ClearContents
mS.Range("A1:A" & lRow) = wArray
End Sub
Random Solutions  
 
programming4us programming4us