Help with pasting formulas using VBA

madsnielsen

New Member
Joined
Oct 4, 2018
Messages
12
Currently doing a project at work, where I am making a standard document, people should be able to make changes to. I am therefore in a situation where I would like for the "Vlookup" function to be pasted. However when using:

rawpurchase.Cells(i, 6) = "=vlookup(E" & i & ",'PurchaseOverview'!A1:C" & nrowover & " ,3,False)"

I am only getting a #name in the field. When entering the field and pressing enter, the results shows. I have tried different solutions, however so far only search for “=” and replace with “=” works, but doing the exact same operation through a macro does not do the job. Also deleting “=” from the celland inserting “=” again, does not change anything either.
I would very much like to avoid anything like the use of send keys etc.
Any help would be much appreciated
?
 
Should there be a space between Purchase & Overview in the Vlookup?
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Yes, the "Purchase Overview" is a reference to another sheet. And I would expect a mistake in this to return the wrong value of the lookup function - which is not the case :/
 
Upvote 0
No it would produce a name error as it can't find the sheet to reference the range but it doesn't explain why it would correct itself by just pressing enter.
 
Upvote 0
I agree with Mark, but what happens if you add the space?
 
Upvote 0
In that case have you tried
Code:
rawpurchase.Cells(i,6).Formula = "= vlookup(E" & i & ",'Purchase Overview'!A1:C" & nrowover & " ,3,False)"
as previously suggested?
 
Upvote 0
Yes your line does run, but does not change the outcome unfortunately. Both with and without the space in front of the "="
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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