I am having trouble with something in my excel sheet and it's probably due to lack of understanding. Basically, I have an IF() statement in cell I2, and for the if_true I would like to run a Public Sub, namely Sub MyFunc() that just copies data from the row to a new sheet.
In other words, I have in cell I2:
=IF(OR(AND($D2="ABOVE", $F2>$E2, $H2="YES"), AND($D2="BELOW", $F2<$E2, $H2="YES")),MyFunc(),"")
This does not seem to run the sub at all and if I run the Sub in the VBE it works fine.
Sub MyFunc()
'begin populating table
'Date
Sheets("Sheet3").Range("A:A").End(xlDown).Offset(1, 0).Value = Format(Now(), "dd/mm/yyyy")
'DayofWeek
Sheets("Sheet3").Range("B:B").End(xlDown).Offset(1, 0).Value = Format(Now(), "ddd")
'copy code and paste in cell
Sheets("Sheet1").Range("A2").Copy Destination:=Sheets("Sheet3").Range("E:E").End(xlDown).Offset(1, 0)
'copy level
Sheets("Sheet1").Range("E2").Copy Destination:=Sheets("Sheet3").Range("F:F").End(xlDown).Offset(1, 0)
'delete row information
Worksheets("Sheet1").Range("A2").ClearContents
Worksheets("Sheet1").Range("C2:E2").ClearContents
Worksheets("Sheet1").Range("G2:H2").ClearContents
'resort colums
SortByMarket
End Sub
Is there any advice I can get in how to call this Sub based on the above condition?
Any help is greatly appreciated :)