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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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
 
Upvote 0
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:
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,756
Members
448,990
Latest member
Buzzlightyear

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
Back
Top