excel vba - Using variables in Sourcedata -


how can code works right, need use variable

act = inputbox("today", "now", thisday)

here need write: 10513 (sheet name).

range("aa2").select

this works ok

activeworkbook.pivotcaches.add(sourcetype:=xldatabase, _ sourcedata:="'10513'!r1c23:r117c23").createpivottable tabledestination:="'[control le.xls]10513'!r4c27", _ tablename:="tabla dinámica3", defaultversion:=xlpivottableversion10 

this doesn't...

activeworkbook.pivotcaches.add(sourcetype:=xldatabase, _ sourcedata:="' act '!r1c23:r117c23").createpivottable _ tabledestination:="'[control le.xls]& act '!r4c27", tablename:="tabla dinámica3", _ defaultversion:=xlpivottableversion10 

you're passing in string act worksheet name. send name (stored in string variable, use string concatenation technique, note differences below:

debug.print "' act '" 

vs.

debug.print "'" & act & "'" 

applying snippet of code, should work:

activeworkbook.pivotcaches.add(sourcetype:=xldatabase, _     sourcedata:="'" & act & "'!r1c23:r117c23").createpivottable _     tabledestination:="'[control le.xls]& act '!r4c27", tablename:="tabla dinámica3", _     defaultversion:=xlpivottableversion10 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -