Results 1 to 2 of 2

Thread: Excel VBA - Array & Range - Help Required
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Aug 2019
    Post Thanks / Like
    0 Post(s)
    0 Thread(s)

    Default Excel VBA - Array & Range - Help Required


    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", _
    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

  2. #2
    Board Regular James006's Avatar
    Join Date
    Apr 2009
    Post Thanks / Like
    19 Post(s)
    1 Thread(s)

    Default Re: Excel VBA - Array & Range - Help Required


    You could add a variable

    Dim last As Long
    last = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
    ' and then amend your instruction
    Array("'Client - MI Report'!BN2:GF" & last)
    Hope this will help

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts