Forum Discussion
Greg Bonaparte
Jul 14, 2019Iron Contributor
CALIBRATE AND RESORT R30:R629
In the following macro I would like macro to sort only if column R30:R629 has at least 24 TRUE entries. The quantitie of TRUE entries are increased by decreasing the value in V15 by decimals (ie 1.0 ...
Brad_Yundt
Jul 14, 2019MVP
You might consider using the Data...What-If Analysis...Goal Seek menu item to adjust the value of cell V15 to get 24 TRUE entries. Goal Seek will require that you have a cell with a formula that counts the TRUE entries.
If V15 must be adjusted in increments of 0.1, GoalSeek can't handle that. So you may end up needing human judgement to decide which value to choose if GoalSeek gives you an "in-between" result.
I rewrote your macro to eliminate the fluff put in it by the macro recorder. the code should run faster as a result.
Sub GreaterThan4k() ' ' GreaterThan4k Macro ' Range("S2").Value = Range("R2").Value Application.EnableEvents = False Range("R2,T2:T27,U2:U11,V2:W5,U30:U629").ClearContents Application.EnableEvents = True ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add2 _ Key:=Range("R30:R629"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("Sheet1").Sort .SetRange Range("B30:BA629") .Header = xlGuess .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With ' Range("R2").Value = Range("S2").Value Range("T2").Value = Range("R2").Value Range("T3").Value = Range("Q10").Value Range("AT30:AT37").Copy Range("T4").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False Range("U2").Value = Range("Q19").Value Range("U3").Value = Range("P10").Value Range("R2").Value = Range("U2").Value Range("AS30:AS31").Copy Range("U4").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False Range("V2").Value = Range("P19").Value Range("V3").Value = Range("P10").Value Range("R2").Value = Range("V2").Value Range("AS30:AS31").Copy Range("V4").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False Range("R2").Select MsgBox "There may be SUGGESTED SHARES to utilize unallocated funds. Add ADDITIONAL SHARES now." End Sub
Greg Bonaparte
Jul 15, 2019Iron Contributor
Thank you, I will try your suggestion and test the non fluff code. Brad_Yundt