Excel VBA Trying to write a “MAX” formula to Cells with different Ranges with For-Loop
问题 I am trying to make VBA write a formula into different cells that will find the maximum value for a Range decided by some variables. My variables I and J are (numbers/Integers). Here is my code. Sub AddMAX() Dim I As Integer Dim J As Integer Dim L As Integer I = InputBox("Number of columns to check max value") J = InputBox("Number of Rows to add formula inn and find max value of that row") For L = 5 To 4 + J Worksheets(1).Cells(L, 4 + I).Formula = "=" & Max(Range(Cells(L, 4), Cells(L, 3 + I))