Excel VBA - Array & Range - Help Required

iGavC

New Member
Joined
Aug 1, 2019
Messages
3
Hi,

I was wondering if anyone could assist.
I'm currently asking my VBA Code to create a multiple consolidated range with a data set I have. It's currently reference within a table which I've named: "Client_MI"

Right now, the data set it going to the 5000th row down. Can I point my range to just simply go to the end of the data source?:

Please see below:
Sub Create_Data_Table()

' Removes alerts

Application.DisplayAlerts = False

' Runs Multiple Consolidated Ranges for Data Table

ActiveWorkbook.PivotCaches.Create(SourceType:=xlConsolidation, SourceData:= _
Array("'Client - MI Report'!R2C66:R5000C188"), Version:=xlPivotTableVersion14). _
CreatePivotTable TableDestination:="", TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion14
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(2, 1)
ActiveSheet.Cells(2, 1).Select
ActiveSheet.PivotTables("PivotTable1").DataPivotField.PivotItems( _
"Count of Value").Position = 1

Application.DisplayAlerts = True

End Sub



Appreciate any assistance on this.

Thank you
Kind regards
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi,

You could add a variable

Code:
Dim last As Long
last = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
' and then amend your instruction
[I]Array("'Client - MI Report'![COLOR=#ff0000]BN2:GF" & last[/COLOR])[/I]

Hope this will help
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

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