+ Reply to Thread
Results 1 to 4 of 4

How to include a Range in a code to create a xlColumnStacked Chart?

  1. #1
    Forum Contributor
    Join Date
    04-22-2014
    Location
    Turrialba, Costa Rica
    MS-Off Ver
    Excel 2010
    Posts
    108

    How to include a Range in a code to create a xlColumnStacked Chart?

    Hello
    I have this code to create a Chart:
    Please Login or Register  to view this content.
    But, when I run the code step by step, VBA displays three graphs and finally creates the graph from Source:=Sheets("Sheet1"). Range("A2:D4")

    However, I need to create the Chart from this code:
    Please Login or Register  to view this content.
    I’ve been googling for hours and I haven’t been able to find a way to include this code
    I appreciate if anyone can help me.

    Cheers all

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: How to include a Range in a code to create a xlColumnStacked Chart?

    See if this will work for you

    Please Login or Register  to view this content.
    BTW the 'Charts.Add' statement does not add a new sheet, it adds a chart to the active sheet.
    Last edited by JLGWhiz; 09-28-2019 at 11:31 PM.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Forum Contributor
    Join Date
    04-22-2014
    Location
    Turrialba, Costa Rica
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: How to include a Range in a code to create a xlColumnStacked Chart?

    First of all, Thank you for your reply.
    Your line of code is new to me and selects the whole range.
    However, from the last column with data, I need to move left two columns.

    This the code edited:
    Please Login or Register  to view this content.
    .

    The next step is from the last row with data to move one rows upwards, but I failed to edit the Offset.

    Even though VBA creates the graph I need, I included this line:
    Please Login or Register  to view this content.
    to delete the Fullseriescollection(1).

    Also, I really appreciate any help to upwards one row from the last row.

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: How to include a Range in a code to create a xlColumnStacked Chart?

    An alternative would be to define your column and row with varibles:

    Please Login or Register  to view this content.
    Which would then find the last row and last column with values and then set the range to exclude the last row and last two columns.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 11-08-2017, 03:24 AM
  2. [SOLVED] need help altering my code to include the ability to choose any column as a search range
    By cmorten82 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-04-2016, 08:46 AM
  3. Modify range of chart series in existing charts to include last column
    By gregersdk in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-05-2015, 08:32 AM
  4. [SOLVED] How to adapt a code to include a range of cells instead of the whole sheet
    By nje in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-08-2013, 08:52 AM
  5. vba code to create chart and fix the axis of the chart
    By Sushil.thakur in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-21-2013, 06:14 AM
  6. Use a function in a chart range so it doesn't include a cell if blank?
    By hokeyplyr48 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-03-2008, 12:32 PM
  7. Replies: 2
    Last Post: 08-05-2005, 01:05 AM

Tags for this Thread

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