Run Macro From If Statement

P

Paige

I could be way off here, but... I am trying to do an IF statement an
then depending on the answer run a macro or end the statement. I
Lotus I was able to do the BRANCH macro, but it seems you cannot d
that in excel. This is an example what I'm trying to accomplish.

If the value of cell M50<= to 25 then do nothing - if it's greater tha
I need another macro to run.

Thank you for any help!
 
P

Paige

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
 
Top