Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, seeking help with 2 follow-ons
to the Sub SortMatch() posted by JBeaucaire in .misc 1. If [D4] = [D8] Then How could the line above be amended to handle the scenario where the condition is approximate, eg: stop the randomization if the absolute value of D4 is within 5% of D8's ? 2. How could the sub be modified to re-generate & "print" several sets of possible result combinations (say 3 result sets) to the right of the source data in A1:B8 (let's assume the source data is to be left intact) Thanks for any insights Max "JBeaucaire" wrote: Similar to above, but rather than manually having to press F9 over and over, here's a layout and a macro to do it in one click: Text Values A1:A8 Numbers B1:B8 Formula in C4 =SUM(B1:B4) Formula in C8 =SUM(B5:B8) Now, here's the macro, run it and it shuffle the data until a matching set is created and then stop. Sub SortMatch() Application.ScreenUpdating = False Columns("C:C").Insert Shift:=xlToRight Range("C1:C8").FormulaR1C1 = "=RAND()" Start: Range("A1:C8").Sort Key1:=Range("C1"), _ Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, _ Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal If [D4] = [D8] Then Columns("C:C").Delete Shift:=xlToLeft MsgBox "Found one set" Else GoTo Start End If Application.ScreenUpdating = True End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Help Modifying Macro | Excel Programming | |||
modifying countifs | Excel Worksheet Functions | |||
Modifying an If Statement | Excel Worksheet Functions | |||
Modifying VLookUp | Excel Worksheet Functions | |||
help Modifying | Excel Worksheet Functions |