I have this code which filters for "RET" and then goes to next active cell. But in case "RET" is not found in the list, the next active cell will be blank and I want it to do nothing and continue on another part of the code and if it is not blank I want it to replace "RET" with 0:
So, in this part it looks for "RET" and then finds next active cell after the filter:
If the active cell is blank I want it to continue here:
If not blank I want it to continue with business as usual!
Thank you very much!
Code:
ActiveSheet.Range("$A$1:$T$1000000").AutoFilter Field:=8, Criteria1:="RET" ActiveSheet.AutoFilter.Range.Offset(1).SpecialCells(xlCellTypeVisible).Cells(1, 8).Select
ActiveCell.FormulaR1C1 = "0"
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.End(xlUp).Select
ActiveSheet.Range("$A$1:$T$1000000").AutoFilter Field:=8
Selection.End(xlToRight).Select
Range("S2").Select
ActiveCell.FormulaR1C1 = _
"=+(RC[-4]*RC[-3]*(1+(RC[-11]/100)))*(1-(RC[-16]/100))"
So, in this part it looks for "RET" and then finds next active cell after the filter:
Code:
ActiveSheet.Range("$A$1:$T$1000000").AutoFilter Field:=8, Criteria1:="RET"
ActiveSheet.AutoFilter.Range.Offset(1).SpecialCells(xlCellTypeVisible).Cells(1, 8).Select
If the active cell is blank I want it to continue here:
Code:
Selection.End(xlUp).Select
ActiveSheet.Range("$A$1:$T$1000000").AutoFilter Field:=8
Selection.End(xlToRight).Select
Range("S2").Select
ActiveCell.FormulaR1C1 = _
"=+(RC[-4]*RC[-3]*(1+(RC[-11]/100)))*(1-(RC[-16]/100))"
If not blank I want it to continue with business as usual!
Thank you very much!