vba to inset a formula into a cell

hitch_hiker

Active Member
Joined
Feb 21, 2012
Messages
294
I have an invoice system , once the data is entered , at the press of a button the worksheet is copied and renamed, as well as printed as a "picking ticket", the input sheet is then cleared of all data and left with the vlookups and formulae, all this works perfect. Sometimes some data is written into cells which replaces the vlookup, as part of my resetting vba, can I get it to replace the cells with the vlookup. E.g. cell a4 has the following vlookup =VLOOKUP(A3,'Customer List'!B:L,2,FALSE), a5 is the same except B:L,3, a6 ~ B:L,4 etc

I'm thinking
activecell = a4
activecell = "=VLOOKUP(A3,'Customer List'!B:L,2,FALSE)"

or could I just go

a4 = "=VLOOKUP(A3,'Customer List'!B:L,2,FALSE)"

not really sure on syntax nor correct commands etc
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Like this?

Code:
Range("A4").Formula = "=VLOOKUP(A3,'Customer List'!B:L,2,FALSE)"
 
Upvote 0
thanks heaps VoG,
I usually know what I want to do , but I struggle on the actual code. but this was just a random tidy up to finish the project off. all works and works well , though I could probably streamline the code but, I don't have to
 
Upvote 0

Forum statistics

Threads
1,216,551
Messages
6,131,310
Members
449,642
Latest member
jobon

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