Problem 2 Using the data table in Excel write code to do the

Problem 2: Using the data table in Excel, write code to do the following: a. Use the Vlookup function to find the cost in June and message box the answer. b. Name the table as “Monthly Energy Bill.” c. Highlight the 4th row using the row property. d. Hide the Demand column.

I need it EXCEL VBA code

Solution


Sub CycleAverage()
Dim lRow As Long

lRow = Range(\"A\" & Rows.Count).End(xlUp).Row
\'Find
totSum = 0
totCount = 0
AvgVolCntr = 1
For iCntr = 1 To lRow
totSum = totSum + Range(\"A\" & iCntr)
totCount = totCount + 1

\'If New Cycle Starts : When I find series of values some thing like this: 2-1-2 or 9-3-4 or a blank
If iCntr > 2 Then
If (Range(\"A\" & iCntr) > Range(\"A\" & iCntr - 1) And _
Range(\"A\" & iCntr - 1) < Range(\"A\" & iCntr - 2)) Or
Range(\"A\" & iCntr) = \"\" Then \'print Averages in Column D & E Range(\"D\" & AvgVolCntr) =
\"Cycle: \" & AvgVolCntr Range(\"E\" & AvgVolCntr) = totSum / totCount \'and set totals to zero totSum = 0 totCount = 0
\'increase AvgVolCntr AvgVolCntr = AvgVolCntr + 1 End If End IfNext iCntrEnd Sub

Problem 2: Using the data table in Excel, write code to do the following: a. Use the Vlookup function to find the cost in June and message box the answer. b. Na

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site