cell formatting problem

cmmadn

Active Member
Joined
Aug 2, 2004
Messages
299
Dear all

Can anyone spot what I am doing wrong and why this should return a 1004 run time error

Code:
Set objwsk3 = Worksheets("Template")
objwsk3.Activate
objwsk3.Range("c3:c500").Formula = "=IF(NOT(ISERROR(VLOOKUP(B3,Vlookup!A:B,2,FALSE))),VLOOKUP(B3,Vlookup!A:B,2,FALSE),"")"
objwsk3.Range("g3:g500").Formula = "=IF(NOT(ISERROR(VLOOKUP(F3,Vlookup!D:E,2,FALSE))),VLOOKUP(F3,Vlookup!D:E,2,FALSE),"")"

any help would be gratefully received

regards

Andrew
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Cbrine

Well-known Member
Joined
Dec 2, 2003
Messages
3,196
objwsk3.Range("c3:c500").Formula = "=IF(NOT(ISERROR(VLOOKUP(B3,Vlookup!A:B,2,FALSE))),VLOOKUP(B3,Vlookup!A:B,2,FALSE),"""")"
objwsk3.Range("g3:g500").Formula = "=IF(NOT(ISERROR(VLOOKUP(F3,Vlookup!D:E,2,FALSE))),VLOOKUP(F3,Vlookup!D:E,2,FALSE),"""")"

You forgot to double up your False response Blank return value within the string. This won't work "", """" will work.


HTH
Cal
 

chiello

Well-known Member
Joined
Jan 18, 2005
Messages
848
Ciao,
if you want to use the characters "" within a string, you have to use an escape sequence, that is double "".
So, "" becomes """" and the entire lines:

...
objwsk3.Range("c3:c500").Formula = "=IF(NOT(ISERROR(VLOOKUP(B3,Vlookup!A:B,2,FALSE))),VLOOKUP(B3,Vlookup!A:B,2,FALSE),"""")"
objwsk3.Range("g3:g500").Formula = "=IF(NOT(ISERROR(VLOOKUP(F3,Vlookup!D:E,2,FALSE))),VLOOKUP(F3,Vlookup!D:E,2,FALSE),"""")"


Does it work??

:biggrin: :biggrin:
 

Forum statistics

Threads
1,147,510
Messages
5,741,574
Members
423,668
Latest member
Audorin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top