I am having a challenge assigning a formula to a cell via VBA. The challenge is that "E16" is blank and is causing the issue. I'm being returned a run-time error 1004. I know the formula works because I can enter it in preceeded with an apostrophe, remove the appostrophe and get this message. After selecting "yes" it works.
Sheets("T&E Input").Range("F16:F16").Formula = "=IF(ISTEXT(E16),VLOOKUP(E16,R_TE_Table,2,FALSE),"")"
Thanks for your suggestions,
John
The line of code is as follows:Code Assistance
-
- GoldLounger
- Posts: 2631
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
Code Assistance
You do not have the required permissions to view the files attached to this post.
Regards,
John
John
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Code Assistance
You must double the quotes within the formula:
Sheets("T&E Input").Range("F16:F16").Formula = "=IF(ISTEXT(E16),VLOOKUP(E16,R_TE_Table,2,FALSE),"""")"
Sheets("T&E Input").Range("F16:F16").Formula = "=IF(ISTEXT(E16),VLOOKUP(E16,R_TE_Table,2,FALSE),"""")"
Best wishes,
Hans
Hans
-
- GoldLounger
- Posts: 2631
- Joined: 26 Jan 2010, 16:31
- Location: Southern California