ecember 2, 2012 no later than 9:00 a.m.
Not really a good vba programmer I really need help
Problem 1. Working with multi-dimensional arrays (25 points)
Descriptions: You are working in the Marketing Department of a company. Your boss wants to target customers who spent $90 or more over a seven-day period in August for a special sales promotion. Your boss wants you to create an application that will sum up the sales transaction data for each customer over the seven-day period. The cumulative sales value for each customer over the seven day period will be recorded on the Problem 1 worksheet, and in column D for each customer who has spent $90 or more your boss wants you to print a red asterisk (i.e., *).
Instructions:
1. Type your code for Problem 1 in Module 1, which has already been inserted.
2. Create a two-dimensional array called custCumSalesArray. This array will have three columns.
3. Copy the data in columns A and B into the first two columns of the custCumSalesArray. Column A contains a list of customer identification number (custID), and Column B contains a list of customer name (custName). The third column in the array will eventually contain the cumulative sales value (cumSales) for each customer.
4. Create a second two-dimensional array called salesDataArray.
5. Copy the Sales Date (dateOfSale), the Sales Amount (salesAmount), and the customer identification number (custID) listed in Columns F through H into the salesDataArray.
6. One by one, go through the sales transactions listed in the salesDataArray and find the corresponding custID in the custCumSalesArray. When you find the matching custID number in the custSalesArray, add the salesAmount for that transaction in the salesDataArray to the cumSales value for that customer. If there are no transactions listed for a custID, then the cumSales value should be 0.
7. Continue Steps 5 and 6 until all the entries in the salesDataArray have been matched up with the corresponding custID in the custCumSalesArray and the cumulative sales value for each customer has been calculated.
8. Print the cumulative sales value for each customer in the Problem 1 worksheet starting in cell C2.
9. Print a red asterisk in column D in the row for any customer who has a cumulative sales value (cumSales) of $150 or more.
10. Place two buttons on the Problem 1 worksheet, one button to run this application, and a second button to restore the data to its original state.
Here is a copy of the problem Im really having a hard time with this program not sure if im right but im trying
Dim custCumSalesArray(14, 2) As Variant
Dim SalesDataArray(17, 2) As Variant
Dim custID As Integer
Dim CustName As String
Dim custSales As Integer
Dim dateofSale As Date
Dim SalesAmount As Integer
Dim i As Integer
Dim j As Integer
With Range("C2")
Range(.Offset(1, 0), .Offset(0, 1).End(xlDown)).ClearContents
End With
With Range("A2")
' Count current salespeople.
custID = Range(.Offset(1, 0), .End(xlDown)).Rows.Count
For i = 1 To custID
custCumSalesArray(15, 0) = .Offset(i, 0).Value
custCumSalesArray(15, 1) = .Offset(i, 1).Value
With Range("G2")
SalesAmount = Range(.Offset(1, 0), .End(xlDown)).Rows.Count
For j = 1 To SalesAmount
SalesDataArray(17, 0) = .Offset(i, 0).Value
SalesDataArray(17, 1) = .Offset(i, 1).Value
' Get this SSN and check if belongs to a person still employed.
If SalesAmount > 90 Then
' Yes, this person is still employed. Add the dollars for
' this sale to the person's total.
SalesDataArray(17, 0) = SalesDataArray(17, 1) + .Offset(j, 2).Value
End If
End With
End Sub
custID custName cumSales dateOfSale salesAmount custID
101 Able 11/08/10 46 113
102 Smith 11/09/10 29 101
103 Brian 11/10/10 39 114
104 Davis 11/11/10 116 107
105 Howard 11/11/10 102 103
106 Lemon 11/12/10 126 101
107 Clark 11/12/10 33 112
108 Emery 11/12/10 122 101
109 Walter 11/14/10 54 110
110 Kent 11/15/10 105 103
111 Rain 11/15/10 45 115
112 Avery 11/16/10 67 108
113 Knott 11/17/10 101 111
114 Brown 11/18/10 64 113
115 Everett 11/19/10 68 114
11/20/10 57 106
11/21/10 89 102
11/22/10 111 108
Not really a good vba programmer I really need help
Problem 1. Working with multi-dimensional arrays (25 points)
Descriptions: You are working in the Marketing Department of a company. Your boss wants to target customers who spent $90 or more over a seven-day period in August for a special sales promotion. Your boss wants you to create an application that will sum up the sales transaction data for each customer over the seven-day period. The cumulative sales value for each customer over the seven day period will be recorded on the Problem 1 worksheet, and in column D for each customer who has spent $90 or more your boss wants you to print a red asterisk (i.e., *).
Instructions:
1. Type your code for Problem 1 in Module 1, which has already been inserted.
2. Create a two-dimensional array called custCumSalesArray. This array will have three columns.
3. Copy the data in columns A and B into the first two columns of the custCumSalesArray. Column A contains a list of customer identification number (custID), and Column B contains a list of customer name (custName). The third column in the array will eventually contain the cumulative sales value (cumSales) for each customer.
4. Create a second two-dimensional array called salesDataArray.
5. Copy the Sales Date (dateOfSale), the Sales Amount (salesAmount), and the customer identification number (custID) listed in Columns F through H into the salesDataArray.
6. One by one, go through the sales transactions listed in the salesDataArray and find the corresponding custID in the custCumSalesArray. When you find the matching custID number in the custSalesArray, add the salesAmount for that transaction in the salesDataArray to the cumSales value for that customer. If there are no transactions listed for a custID, then the cumSales value should be 0.
7. Continue Steps 5 and 6 until all the entries in the salesDataArray have been matched up with the corresponding custID in the custCumSalesArray and the cumulative sales value for each customer has been calculated.
8. Print the cumulative sales value for each customer in the Problem 1 worksheet starting in cell C2.
9. Print a red asterisk in column D in the row for any customer who has a cumulative sales value (cumSales) of $150 or more.
10. Place two buttons on the Problem 1 worksheet, one button to run this application, and a second button to restore the data to its original state.
Here is a copy of the problem Im really having a hard time with this program not sure if im right but im trying
Dim custCumSalesArray(14, 2) As Variant
Dim SalesDataArray(17, 2) As Variant
Dim custID As Integer
Dim CustName As String
Dim custSales As Integer
Dim dateofSale As Date
Dim SalesAmount As Integer
Dim i As Integer
Dim j As Integer
With Range("C2")
Range(.Offset(1, 0), .Offset(0, 1).End(xlDown)).ClearContents
End With
With Range("A2")
' Count current salespeople.
custID = Range(.Offset(1, 0), .End(xlDown)).Rows.Count
For i = 1 To custID
custCumSalesArray(15, 0) = .Offset(i, 0).Value
custCumSalesArray(15, 1) = .Offset(i, 1).Value
With Range("G2")
SalesAmount = Range(.Offset(1, 0), .End(xlDown)).Rows.Count
For j = 1 To SalesAmount
SalesDataArray(17, 0) = .Offset(i, 0).Value
SalesDataArray(17, 1) = .Offset(i, 1).Value
' Get this SSN and check if belongs to a person still employed.
If SalesAmount > 90 Then
' Yes, this person is still employed. Add the dollars for
' this sale to the person's total.
SalesDataArray(17, 0) = SalesDataArray(17, 1) + .Offset(j, 2).Value
End If
End With
End Sub
custID custName cumSales dateOfSale salesAmount custID
101 Able 11/08/10 46 113
102 Smith 11/09/10 29 101
103 Brian 11/10/10 39 114
104 Davis 11/11/10 116 107
105 Howard 11/11/10 102 103
106 Lemon 11/12/10 126 101
107 Clark 11/12/10 33 112
108 Emery 11/12/10 122 101
109 Walter 11/14/10 54 110
110 Kent 11/15/10 105 103
111 Rain 11/15/10 45 115
112 Avery 11/16/10 67 108
113 Knott 11/17/10 101 111
114 Brown 11/18/10 64 113
115 Everett 11/19/10 68 114
11/20/10 57 106
11/21/10 89 102
11/22/10 111 108