For reasons I don't understand my vba macro gets stuck on this line:
ActiveCell.Formula = "=IF(OR(A7=""Account"",AND(LEFT(A7,2)=""ID"",A8=""Account""),A7=""),"",IF(RIGHT(A7,1)="")"",SUBSTITUTE(SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE(A7,"" "",REPT("" "",100)),100)),""("",""),"")"",""),A7))"
For reference, the original manually inputted formula (with fewer speechmarks and which works) is:
=IF(OR(A7="Account",AND(LEFT(A7,2)="ID",A8="Account"),A7=""),"",IF(RIGHT(A7,1)=")",SUBSTITUTE(SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE(A7," ",REPT(" ",100)),100)),"(",""),")",""),A7))
Any suggestions what the issue is please?
I'm guessing it's an issue with the OR function as subsequent lines are enacted no problem:
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Formula = "=IF(AND(LEFT(A7,2)=""ID"",A8=""Account""),TRIM(MID(A7,4,FIND("" "",MID(A7,4,20)))),F6)"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Formula = "=B7-C7"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Formula = "=TEXT(IF(AND(LEFT(A7,2)=""ID"",A8=""Account""),C7,H6),""dd/mm/yyyy"")"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Formula = "=TEXT(IF(AND(LEFT(A7,2)=""ID"",A8=""Account""),SUBSTITUTE(MID(MID(A7,FIND(""Posted by"",A7),99),FIND("" on "",MID(A7,FIND(""Posted by"",A7),99))+4,12),"")"",""""),I6),""dd/mm/yyyy"")"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Formula = "=IF(AND(LEFT(A7,2)=""ID"",A8=""Account""),IF(MID(A7,FIND(""Posted by "",A7)-1,1)=""("","""",MID(A7,FIND(""("",A7,FIND(""Posted by "",A7)-20)+1,FIND("": Posted by "",A7)-FIND(""("",A7,FIND(""Posted by "",A7)-20)-1)),J6)"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Formula = "=IF(AND(LEFT(A7,2)=""ID"",A8=""Account""),(MID(A7,FIND(""Posted by"",A7)+10,FIND("" on "",A7,FIND(""Posted by"",A7)+10)-FIND(""Posted by"",A7)-10)),K6)"
ActiveCell.Offset(0, 2).Range("A1").Select
ActiveCell.Formula = "=IF(AND(LEFT(A7,2)=""ID"",A8=""Account""),MID(A7,FIND("" "",A7,4)+1,FIND(IF(MID(A7,FIND(""Posted by "",A7)-1,1)=""("",""(Posted by "",""(Manual Journal: Posted by ""),A7)-FIND("" "",A8,4)-2),M6)"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Formula = "=IF(AND(LEFT(A7,2)=""ID"",A8=""Account""),RIGHT(A7,LEN(A7)-FIND("")"",A7,FIND(""Posted by "",A7))-1),N6)"
ActiveCell.Offset(0, -9).Range("A1").Select