Results 1 to 2 of 2

Dynamic Chart VBA data range issue

Threaded View

  1. #1
    Registered User
    Join Date
    04-02-2015
    Location
    London
    MS-Off Ver
    2013
    Posts
    3

    Dynamic Chart VBA data range issue

    Hi, ive used some code from a youtube video ive found and altered it to fit my data range. However, the chart is now calculating all the blank cells beneath it. I'm very new to all this and so not entirely sure what I'm doing. Any help would be greatly appreciated. Here's the code before:

    Dim chtobj As ChartObject
    
     lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
    Set chtrng = Range("a1:c" & lr)
    
     Set ChartArea = Range("c" & lr + 3 & ":h" & lr + 15)
     ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
     ActiveChart.SetSourceData Source:=chtrng
     Set chtobj = ActiveChart.Parent
    
     chtobj.Top = ChartArea.Top
     chtobj.Left = ChartArea.Left
     chtobj.Height = ChartArea.Height
     chtobj.Width = ChartArea.Width
     ActiveChart.ClearToMatchStyle
     ActiveChart.ChartStyle = 209
    And this is what I've changed as my data starts in h20, i20 and j20.

    Dim chtobj As ChartObject
    
     lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
    Set chtrng = Range("h20:j20" & lr)
    
     Set ChartArea = Range("c" & lr + 3 & ":h" & lr + 15)
     ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
     ActiveChart.SetSourceData Source:=chtrng
     Set chtobj = ActiveChart.Parent
    
     chtobj.Top = ChartArea.Top
     chtobj.Left = ChartArea.Left
     chtobj.Height = ChartArea.Height
     chtobj.Width = ChartArea.Width
     ActiveChart.ClearToMatchStyle
     ActiveChart.ChartStyle = 209
    Last edited by 6StringJazzer; 04-08-2015 at 01:17 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. add excel data in body email (data range is dynamic) & signature issue
    By Marijke in forum Outlook Programming / VBA / Macros
    Replies: 3
    Last Post: 11-25-2014, 05:41 AM
  2. [SOLVED] Dynamic Named Range issue with Data Validation
    By bamaisgreat in forum Excel General
    Replies: 5
    Last Post: 11-29-2012, 02:07 PM
  3. Chart Title from Dynamic Range Issue
    By a2excel in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 07-10-2012, 03:41 AM
  4. Replies: 3
    Last Post: 07-29-2010, 02:27 PM
  5. Dynamic Data Range Issue
    By MackAttack26 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-12-2009, 03:55 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1