substitute strings with variables

B

banavas

I have the following two problems:

1. I want to substitute the string "A_030716_cl_max_val_EK" with
variable (filestringL) that contains this string. How can I do tha
(see statement following)?

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:
"A_030716_cl_max_val_EK!R1C1:R74C11").CreatePivotTabl
TableDestination:="", _
TableName:="PivotTable2"
DefaultVersion:=xlPivotTableVersion10

2. I want to substitute in the following statement the 9000 with a
integer that contains the value. Any ideas?

ActiveCell.FormulaR1C1 = _
"=VLOOKUP(Members,
Code
 
K

Kris

banavas,

You need to concatinate the variables with the strings
with the "&" character. Like:

Dim MyString as String

Mystring = "A_030716_cl_max_val_EK"

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase,_
SourceData:=
Mystring & "!R1C1:R74C11").CreatePivotTable _
TableDestination:="", _
TableName:="PivotTable2", _
DefaultVersion:=xlPivotTableVersion10

Dim MyRow as Integer

MyRow = 9000

ActiveCell.FormulaR1C1 = _
"=VLOOKUP(Members,' _
Code: _
--------------------
s Sheet1'!R2C1:R" & MyRow & "C7,5,0)"

-----Original Message-----
I have the following two problems:

1. I want to substitute the
string "A_030716_cl_max_val_EK" with a
 
T

Tom Ogilvy

Dim i as long, sStr as String

sStr = "A_030716_cl_max_val_EK"
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=
sStr & "!R1C1:R74C11").CreatePivotTable
TableDestination:="", _
TableName:="PivotTable2",
DefaultVersion:=xlPivotTableVersion10

i = 9000

ActiveCell.FormulaR1C1 = _
"=VLOOKUP(Members,'s Sheet1'!R2C1:R" & i & "C7,5,0)"
 
Top