I've been searching for a few days trying to figure this out however my feeble brain cannot solve this.
Here's the deal..... I am trying to find the max value within a range (14 cells) contained in one column ("C" in this case). This range will change corresponding to the current cell. Ex. as the current cell moves down (or increases in number) the range of cells to find the Max in moves down (or increases in number) as well. The Max value will then be used as a variable in a equation but for now just getting it into a cell is fine. This seems like it would be easy but it is driving me absolutely batty!
I currently have the non-working code located in a For loop that contains other calculations as well. I've taken those calculations out since they work fine but cloud the bad part.
So far I have tried:
No dice... so I tried:![]()
For EMA_20 = 20 To 28 MaxVal = Sheets(rv1).Range(Sheets(rv1).Cells(EMA_20 - 13, 3), Sheets(rv1).Cells(EMA_20, 3)).Max rv1.Cells(EMA_20, 7) = MaxVal Next
Finally:![]()
For EMA_20 = 20 To 28 MaxVal = Application.WorksheetFunction.Max(Range(rv1.Cells(EMA_20 - 13, 3), rv1.Cells(EMA_20, 3))) rv1.Cells(EMA_20, 7) = MaxVal Next
Most of the time I get runtime error 9 Subscript out of range.![]()
For EMA_20 = 20 To 28 Dim MyRange As Range Dim Startrng Dim Endrng Startrng = EMA_20 - 13 Endrng = EMA_20 Set MyRange = Range(Cells(Startrng, 3), Cells(Endrng, 3)) MaxVal = MyRange.Find(What:=WorksheetFunction.Max(MyRange), LookIn:=xlValues) rv1.Cells(EMA_20, 7) = MaxVal Next
The fix is probably very simple but like I said, I have a feeble mind.Thanks in advance for any help/hints!!
Robert











LinkBack URL
About LinkBacks

Thanks in advance for any help/hints!!
Register To Reply

Bookmarks