简体   繁体   中英

VBA Excel if Cell Is Not Equal to formula then

I want to check if a cell is this formula then execute a part 2 script

The code Simplified

Range("B1:C1").Select
If ActiveSheet.Name = "Sheet1" And ActiveCell <> "=formula1" Then Sheet1Macro

the complete code (long)

Range("B1:C1").Select
If ActiveSheet.Name = "Sheet1" And ActiveCell <> "=IF(OR(IFERROR(SEARCH(""DKB"",RC[-2]),0),IFERROR(SEARCH(""Cox"",RC[-2]),0),IFERROR(SEARCH(""2020"",RC[-2]),0)),RC[-1],"""")" Then Sheet1Macro

I'm just asking on how to check if the cell is a formula because I insert rows and that changes the formula from A2:F99 to A99:F189 for example

If ActiveSheet.Name = "Sheet1" And Range("B1").FormulaR1C1 = "=IF(OR(IFERROR(SEARCH(""DKB"",RC[-2]),0),IFERROR(SEARCH(""Cox"",RC[-2]),0),IFERROR(SEARCH(""2020"",RC[-2]),0)),RC[-1],"""")" Then Sheet1Macro

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM