Hi Cindy,
I have received your code from the macro you have recorded.
I cannot tell much myself but first to define a name for your pivot table. T=
his can be done in Excel in the formula tab "define name" then check in "Na=
me manage" if you run 2007 or 2010 or the insert menu I think if you run 20=
03,tough it is still called up with "define name" or "name manager".
Then in your code, replace the field of the worksheet you want to query in =
the vlookup function with the name you have defined. I can see in your code=
ActiveCell.FormulaR1C1 =3D "=3DVLOOKUP(Sheet1!RC[-2],'navision '!R2C1:R800=
0C13,12,FALSE)"
ActiveCell.FormulaR1C1 =3D "=3DVLOOKUP(RC[-13],Sheet1!R5C1:R3000C3,2,FALSE=
)"
=20
The reason your code does not find the vlookup value is when you record it, =
you change worksheets, at one point you apply vlookup onto another workshee=
t (navision) and later on from this worksheet, you apply vlookup. Moreover,=
I do not know if you have ticked relative reference when you have created the m=
acro but if it is the case, if you are moving while recording your macro, run=
ning your macro can be different... And last thing which makes things not e=
asy, your using column row notation, this is a good thing if you want to ge=
t into coding but at many levels "A1, B2..." notation is more simple.
So for now, I can just tell you to define a name for your pivot table and u=
se that same name in the vlookup: "=3DVLOOKUP(Sheet1!RC[-2],NEWNAME,12=
,FALSE)" position yourself after the "[-2]," coma and press F3, it will bri=
ng the name you have defined automatically.
Apply this to the other vlookup formula and it should be working.
HTH,
Pascal Baro