Home |
Search |
Today's Posts |
#3
![]() |
|||
|
|||
![]() I can't get it to work. How caan I run it from within a Sub? What I am doing is automating a form. When the user chooses the quantities and products it then sorts them and deletes any rows not needed. If there are more than 25 lines I need it to one thing and if it's less another thing. Below is my code up until where I'm stuck. (It may be kind of ugly as I'm quite new to excel...) Sub AfterSort() Range("A2:I997").Select Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Key2:=Range("E2") _ , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _ False, Orientation:=xlTopToBottom Application.Goto Reference:="PODATABASE" ActiveCell.FormulaR1C1 = "end" Selection.End(xlUp).Select ActiveCell.Offset(1, 0).Activate Range(Selection, Selection.End(xlDown)).Select Selection.EntireRow.Delete Application.Goto Reference:="END1" Selection.End(xlUp).Select ActiveCell.Offset(1, 0).Range("A1").Select Selection.End(xlToRight).Select Range(Selection, Selection.End(xlDown)).Select Selection.ClearContents ActiveCell.Offset(0, -1).Range("A1").Select Range("A2:I27").Select Selection.Sort Key1:=Range("I2"), Order1:=xlAscending, Key2:=Range("E2") _ , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _ False, Orientation:=xlTopToBottom ActiveCell.Select Range("A2:H27").Select Selection.Copy Sheets("Purchase Order").Select Application.Goto Reference:="POQTY" ActiveSheet.Paste Application.Goto Reference:="POQTY" ActiveWorkbook.Names("PODATABASE").Delete ActiveWorkbook.Names("PONUMBER").Delete ActiveWorkbook.Names("POQTY").Delete ActiveWorkbook.Names("POREQUIREDBY").Delete ActiveWorkbook.Names("POVALUE").Delete ActiveWorkbook.Names("POMERGE").Delete ActiveWorkbook.Names("POJOBNO").Delete ActiveWorkbook.Names("POVENDOR").Delete 'THIS IS WHERE I NEED TO HAVE IT CHOOSE BETWEEN CONTINUING IF THE TOTAL IS MORE THAN 25 OR END CODE IF 25 OR LESS End Sub -- Paige ------------------------------------------------------------------------ Paige's Profile: http://www.excelforum.com/member.php...o&userid=23096 View this thread: http://www.excelforum.com/showthread...hreadid=376081 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
can i use an IF Statement to run a macro? | Excel Worksheet Functions | |||
If statement in a Macro | Excel Discussion (Misc queries) | |||
how do i change the expense statement template macro | Excel Worksheet Functions | |||
if statement in Macro | Excel Worksheet Functions | |||
Macro and If Statement | Excel Discussion (Misc queries) |