I have an assignment for school I need to get done and I cannot figure out the right codes for this for the life of me. This is my first course in VBA and I really need some help badly! Heres the project:

CS385: Project 1

Check Calendar for Due Date





Create a macro called Calculations that will perform the following tasks:



1. Prompt the user to enter three numbers and store them in appropriate variables.



2. Create a private function Min which will take the three variables as arguments. The procedure will determine the smallest of the three numbers entered by the user and return it to a variable named Smallest using an assignment statement.



3. Create a private function Max which will take three variables as arguments. The procedure will determine the largest of the three numbers entered by the user and return it to a variable named Largest using an assignment statement.



4. Determine if each variable is even or odd and print the variable and result to the spreadsheet.



5. Output the following with labels starting in cell A1:

a. All three numbers entered by the user.

b. Smallest of numbers entered by the user.

c. Largest of numbers entered by the user.

g. Numbers are Even or Odd

h. Column A should be resized using code to the widest statement



6. Save the workbook in this form CollegeJoeHW1.xls and submit it to WebCT.


Sample Output Results:


Column A in Excel Column B in Excel
First number= 46
Second number= 68
Third number= 23
The largest nuber is 68
The smallest number is 23
The number 45 is odd
The number 68 is even
The number 23 is odd


*He gave us a starter code for it:

This is some code to get you started on Project 1.

Option Explicit

Public Sub Calculation()

'Define variables

Dim Var1 As Long, Var2 As Long, Var3 As Long, Largest As Integer, Smallest As Integer

'Input 3 numbers from user

Var1 = InputBox("Enter the first integer :", "First")

Var2 = InputBox("Enter the second integer :", "Second")

Var3 = InputBox("Enter the third integer :", "Third")

'Write information to the spreadsheet

Range("a1").Value = "First number = "

Range("a2").Value = "Second number = "

Range("a3").Value = "Third number = "

Range("b1").Value = Var1

Range("b2").Value = Var2

Range("b3").Value = Var3

'Find the Largest Number

Largest = Max(Var1, Var2, Var3)

Range("a4").Value = "The largest number is " & Largest

'Find the Smallest Number

Smallest = Min(Var1, Var2, Var3)

Range("a5").Value = "The smallest number is " & Smallest

If Var1 Mod 2 = 0 Then

Range("a6").Value = "The number " & Var1 & " is even"

Else

Range("a6").Value = "The number " & Var1 & " is odd"

End If

If Var2 Mod 2 = 0 Then

Range("a7").Value = "The number " & Var2 & " is even"

Else

Range("a7").Value = "The number " & Var2 & " is odd"

End If

If Var3 Mod 2 = 0 Then

Range("a8").Value = "The number " & Var3 & " is even"

Else

Range("a8").Value = "The number " & Var3 & " is odd"

End If

Columns("a:a").EntireColumn.AutoFit

End Sub

You will need to create the Max Function and Min Function in the following form:

Private Function Max(Var1 As Integer, Var2 As Integer, Var3 As Integer) As Integer

‘Place your If statements here from Computer Exercise 2, Problem 4 which finds the largest and smallest values from three integers
End Function

*Then he gave us another function code to check if we were right. He gave us the Min and Max function:

Private Function Min(v1 As Long, v2 As Long, v3 As Long) As Long

If v1 < v2 And v1 < v3 Then

Min = v1

ElseIf v2 < v1 And v2 < v3 Then

Min = v2

ElseIf v3 < v1 And v3 < v2 Then

Min = v3

End If

End Function

Private Function Max(v1 As Long, v2 As Long, v3 As Long) As Long

If v1 > v2 And v1 > v3 Then

Max = v1

ElseIf v2 > v1 And v2 > v3 Then

Max = v2

ElseIf v3 > v1 And v3 > v2 Then

Max = v3

End If
End Function





*If anyone give me the correct code so I can figure out my mistakes please. I would be very thankful!!