I am unsure how to complete this VBA code. The list the program is reading from
ID: 3886717 • Letter: I
Question
I am unsure how to complete this VBA code. The list the program is reading from is (C5 to C30) and i am trying to have VBA automatically write the maximum value in F13, Average value in F14, and Minimum value in F15
Function List () initialize x - Sheets ("List") .Cells (6, 3) 'reads first element of the list 'Max stores the maximum of all numbe rs in the 1ist Max-xinitialize variable Max to the first element ' Min stores the minimum of all numbers in the 1ist Min = x ' initialize variable Min to the first element 'Sum stores the sum of all numbers in the list Sum x'initialize variable Sum to the firstelement because the first element is already read start reading from the excel sheet from row 7 to row 30 'iteration begins For i 2 To 25 Step 1 Next i iteration ends the program has read all the numbers in list from row 6 to row 30 Avg - Sum / 25'calculate the average Sheets ("List") .Cel1s (13, "F") -Max'write maximum Sheets ("List").cells (14, "F") -Avg ' write ave rage Sheets ("List").Cells (15, "F") - Min 'write minimum End Sub 4: List of 25 Numbers Use Worksheet List in Hw2_X.xlsm file along with the user-defined VBA function List to solve this problem. No extra file is required to be submitted other than the HW_2_X.xlsm file that should contain the Worksheet List and the VBA function List VBA function List should find the maximum, minimum, and average from the list of numbers. Complete the Table 5 using the user-defined VBA function ListExplanation / Answer
Hi,
Kindly use the below VBA code. If you face any issue, let me know -
Sub Macro1()
'
' Macro1 Macro
'
'
Range("F13").Select
ActiveCell.FormulaR1C1 = "=MAX(R[-8]C[-3]:R[17]C[-3])"
Range("F14").Select
ActiveCell.FormulaR1C1 = "=AVERAGE(R[-9]C[-3]:R[16]C[-3])"
Range("F15").Select
ActiveCell.FormulaR1C1 = "=MIN(R[-10]C[-3]:R[15]C[-3])"
Range("F16").Select
End Sub
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.