Vijaychitra
New Member
Hello,
Tried to use the below IF conditions in excel, I'm able to get the required data in the column. However when I tried to add the same condition in VB MACRO with multiple IF conditions, the macro throws an compilation error.
In EXCEL
=IF(ISNUMBER(SEARCH("APPLE",J4)),"APPLE", IF(ISNUMBER(SEARCH("MAT",J4)),"MAT",IF(ISNUMBER(SEARCH("CAT",J4)),"CAT"))) - Works
In MACRO
Range("B2:B" & last_row).Formula = =IF(ISNUMBER(SEARCH("APPLE",J4)),"APPLE", IF(ISNUMBER(SEARCH("MAT",J4)),"MAT",IF(ISNUMBER(SEARCH("CAT",J4)),"CAT")))
It throws a completion error.
In EXCEL
=IF(COUNT(SEARCH("APPLE",J4)),"APPLE", IF(COUNT(SEARCH("MAT",J4)),"MAT",IF(COUNT(SEARCH("CAT",J4)),"CAT")))- Works
In MACRO
Range("B2:B" & last_row).Formula = IF(COUNT(SEARCH("APPLE",J2)),"APPLE"),IF(COUNT(SEARCH("MAT",J2)),"MAT"),IF(COUNT(SEARCH("CAP",J2)),"CAP"))))
It throws a completion error.
Let me know how the above 2 IF conditions can be incorporated in VB MACRO with multiple IF conditions?
Thanks...
Tried to use the below IF conditions in excel, I'm able to get the required data in the column. However when I tried to add the same condition in VB MACRO with multiple IF conditions, the macro throws an compilation error.
In EXCEL
=IF(ISNUMBER(SEARCH("APPLE",J4)),"APPLE", IF(ISNUMBER(SEARCH("MAT",J4)),"MAT",IF(ISNUMBER(SEARCH("CAT",J4)),"CAT"))) - Works
In MACRO
Range("B2:B" & last_row).Formula = =IF(ISNUMBER(SEARCH("APPLE",J4)),"APPLE", IF(ISNUMBER(SEARCH("MAT",J4)),"MAT",IF(ISNUMBER(SEARCH("CAT",J4)),"CAT")))
It throws a completion error.
In EXCEL
=IF(COUNT(SEARCH("APPLE",J4)),"APPLE", IF(COUNT(SEARCH("MAT",J4)),"MAT",IF(COUNT(SEARCH("CAT",J4)),"CAT")))- Works
In MACRO
Range("B2:B" & last_row).Formula = IF(COUNT(SEARCH("APPLE",J2)),"APPLE"),IF(COUNT(SEARCH("MAT",J2)),"MAT"),IF(COUNT(SEARCH("CAP",J2)),"CAP"))))
It throws a completion error.
Let me know how the above 2 IF conditions can be incorporated in VB MACRO with multiple IF conditions?
Thanks...