You are on page 1of 1

Excel Analytics and Programming Assignment 1

At a fair, the participants were asked to input their name in the first column and their Columbia University UNI on the second column of an Excel document. Write the codes in VBA that can complete the task of automating the process by which the collected UNIs can be bundled together into one text, which can be directly pasted into an email to send out to all participants. Display this in cell D1. Recall that a valid address has the form [UNI]@columbia.edu, and that when an email is sent to multiple recipients, a comma followed by a space is used to separate the contacts. However, despite the directions, some participants did not follow directions and did not input merely their UNI on the second column; instead, they entered their entire email address. UNIs can vary in length. The first few entries of the data record may look like this:

For a sample data like this, the output of the assignment will generate the following text: gz2165@columbia.edu, aaa111@columbia.edu, bbb222@columbia.edu, myemail@gmail.com, xyz999@columbia.edu Hint: look for patterns. What pattern is observed for all UNI entries that didnt follow the direction? As a guide, here are some string functions in VBA with illustrations of their syntaxes. All text in bold and italics corresponds to actual VBA codes. Note, not all of these functions need to be used: Concatenation & Length To join Hi and class with a space between: hi & & class Len(hello) will return 5 Find InStr("abcdefg", "cd") returns the index at which cd first appears, which is 3 InStr("abcdefg", "x") returns 0 as x is not found in the string InStr(3, "ababcd", "b") finds the index of the first instance of b starting at index 3, which is 4 Split Mid("ABCDEF", 2) returns the substring from the 2nd entry until the end, which is BCDEF Mid("ABCDEF", 2, 3) returns the substring from the 2nd entry, of length 3, which is BCD Left("abcdefg", 4) returns the first 4 characters of the string, which is abcd Right("abcdefg", 4) returns the last 4 characters of the string, which is defg Trim(abc ) gets rid of the extra spaces at the end and returns abc

You might also like