CONCATENATE in VBA equation

Larsen

New Member
Joined
Sep 23, 2011
Messages
2
Hi Everyone,

I am trying to pull some data from a pivot table and store it in a variable. I need to use the CONCATENATE function in order to pull the different parts of the pivot table together because I am using a variable called Price_Band.

Right now I am just outputting it to the active cell so I can see if it works.

I keep getting the error "Sub or function not defined"

I am not sure if I need to call a library since I am using the CONCATENATE function in VBA which is a first for me. I have created this equation in a cell and it works.

Can anyone out there please let me know if they see something wrong.

Sub Get_Volumes()
Dim Green_Book As PivotTable
Dim Price_Band As String

Price_Band = "1700-1799" ' this is a price band in my pivot table so doing this here to assign the variable. Once this works this will come from a cell in the excel sheet.

Set Green_Book = Sheets("Green_book").PivotTables(1)

ActiveCell.Value = Green_Book.GetPivotData("[Measures].[CPU Units]", "[DIM OEM].[OEM]", "[DIM OEM].[OEM].&[Acer]", "[DIM Sub FF].[Sub FF]", "[DIM Sub FF].[Sub FF].&[Trad]", "[DIM Quarter].[Quarter]", "[DIM Quarter].[Quarter].&[2009Q2]", "[DIM System PB].[System PB]", CONCATENATE("[DIM System PB].[System PB].&[" & Price_Band & "]"))

End Sub

FYI - I am a intermediate C++ programmer who taught myself VBA so feel free to make suggestions.

Thanks!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Try losing the CONCATENATE (that is a worksheet function)

Code:
ActiveCell.Value = Green_Book.GetPivotData("[Measures].[CPU Units]", "[DIM OEM].[OEM]", "[DIM OEM].[OEM].&[Acer]", "[DIM Sub FF].[Sub FF]", "[DIM Sub FF].[Sub FF].&[Trad]", "[DIM Quarter].[Quarter]", "[DIM Quarter].[Quarter].&[2009Q2]", "[DIM System PB].[System PB]", "[DIM System PB].[System PB].&[" & Price_Band & "]")
 
Upvote 0
Thanks VOG it works!!! who would have thought taking something away would make it work. I will remember that for the future.
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,486
Members
452,917
Latest member
MrsMSalt

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