PLEASE SHOW VB CODES USED Create a sub that presents the num

PLEASE SHOW VB CODES USED:

Create a sub that presents the number of customers that have a reservation for flight FlightNr1 to flight with FlightNr6.

Create a sub that calculates the average amount of payments made.

TktNo CustomerId FlightNo Class BookingDate TravelDate NoInfants MealPref PaymentMode PayAmt
1 C001 1 Economy 2/5/2002 3/5/2001 0 Asian Veg Check $210.00
2 C003 1 Business 4/5/2002 5/5/2003 1 Non Veg Cash $210.00
3 C003 1 Business 5/14/2002 6/14/2003 1 Non Veg - Dairy Credit card $360.00
4 C007 2 Economy 12/1/2001 1/1/2003 2 Non Veg Credit Card $230.00
5 C009 2 Business 4/5/2002 5/5/2003 0 Asian Veg Credit Card $360.00
6 C010 3 Economy 2/3/2002 3/3/2003 0 Asian Veg Check $310.00
7 C014 3 Economy 6/7/2002 6/7/2003 0 Non Veg - Dairy Credit card $310.00
8 C012 3 Club 6/7/2002 6/7/2003 1 Non Veg Credit Card $560.00
9 C003 4 Economy 5/3/2002 8/3/2003 1 Veg Credit Card $130.00
10 C004 4 Economy 5/20/2002 6/20/2003 0 Asian Veg Credit Card $130.00
11 C011 5 Economy 12/7/2001 3/7/2003 0 Asian Veg Credit Card $210.00
12 C012 5 Club 4/1/2002 7/1/2003 0 Asian Veg Credit Card $510.00
13 C014 6 Business 4/2/2002 7/2/2003 1 Non Veg - Dairy Check $160.00
14 C013 6 Club 6/1/2002 9/1/2003 0 Non Veg - Dairy Credit Card $260.00

Solution

Passenger count:

Sub GetPassengerCount()
Dim myRange As Range
Dim cell As Range
Dim passengers(6) As Integer
  
Set myRange = Sheets(\"Sheet1\").Range(\"C2:C15\")
  
For Each cell In myRange
passengers(cell) = passengers(cell) + 1
Next cell
  
  
MsgBox \"Count in each flight = {\" & passengers(1) & \",\" & passengers(2) & \",\" & passengers(3) & \",\" & passengers(4) & \",\" & passengers(5) & \",\" & passengers(6) & \"}\"
End Sub

\'#################################################################################

Average Sub:

Sub SumRange()
Dim myRange As Range
Dim cell As Range
Dim rngtotal As Double
Dim avg As Double
  
Set myRange = Sheets(\"Sheet1\").Range(\"J2:J15\")
  
For Each cell In myRange
rngtotal = rngtotal + cell
Next cell
  
avg = rngtotal / 15
  
MsgBox \"The Average of Range(\'\'J2:J15\'\') = \" & avg
End Sub

PLEASE SHOW VB CODES USED: Create a sub that presents the number of customers that have a reservation for flight FlightNr1 to flight with FlightNr6. Create a su
PLEASE SHOW VB CODES USED: Create a sub that presents the number of customers that have a reservation for flight FlightNr1 to flight with FlightNr6. Create a su

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site