Results 1 to 2 of 2

Excel unit ranges to ppt does not paste correctly

Threaded View

  1. #1
    Registered User
    Join Date
    05-08-2015
    Location
    Gothenburg
    MS-Off Ver
    2013
    Posts
    7

    Excel unit ranges to ppt does not paste correctly

    I have a excelsheet with loads of data that is filtered, sorted och then two ranges are combined using union. Thesee ranges, a header and chart is the copied to a ppt.
    After this is done the script should look fot the next part of the table and union then puts the main categories with the new content together in a range and is pasted to a ppt with the new header and a new graph.

    Everything works fine except that for some reason, the range that I pass to the ppt does not only take the new range, it takes the new with the old one and pastes it into the ppt.

    When I use the immidiate window and just paste the range into a blank excel it looks right. But for some reason it does not takes the old and new range. For every loop this range just gets larger and larger.

    Can someone tell me what I'm doing wrong?

    A part of my code:

        'Add the header and the cars
        Set pptHeader = Range(Cells(1, 2), Cells(3, lastCarColumn))
        
        'Content to follow with the header
        'Set pptContent = Range(Cells(4, 2), Cells(5, lastCarColumn))
        Set pptContent = Range(Cells(topRangeRow, 2), Cells(bottomRangeRow, lastCarColumn))
        
        'Combining the ranges
        Set pptTotal = Union(pptHeader, pptContent) '.Select
        pptTotal.SpecialCells(xlCellTypeVisible).Copy
        
        'Getting the content header and compare to the Chart Title
        Dim oChart As ChartObject
        Dim oCharts As ChartObjects
        Dim header, slideHeader As String
        Dim headerRow As Integer
        
        'Get the content header
        headerRow = pptContent.Rows.Count
        header = pptContent(pptContent.Rows.Count, 1).Value
     
        
        'Loops through all charts in the Chart sheet and looks for the right header
        For Each oChart In sht3.ChartObjects
            oChart.Activate
            If oChart.chart.HasTitle Then
                If activeChart.ChartTitle.Text = header Then
                    slideHeader = activeChart.ChartTitle.Text
                    Debug.Print slideHeader
                    Exit For
                End If
            End If
        Next oChart
        
        'Calls function/sub that copy/pastes the content to the ppt
        excelRangeToPpt (pptTotal)
        
        'Calls function to set slide Chart
        setSlideChart
        
        'Calls function to set slide header title
        excelTitleToPpt (slideHeader)
        
        'Resetting
        Application.CutCopyMode = False
        Set pptHeader = Nothing
        Set pptContent = Nothing
        Set pptTotal = Nothing
        sht1.Activate
        ActiveCell.Offset(1, 0).Activate
        Application.ScreenUpdating = True
    Last edited by davva23; 07-03-2017 at 06:58 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. display unit on axis (unit that's less than 1)
    By hoda in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-21-2016, 08:16 PM
  2. Find previous number of certain unit and paste in current cell
    By firmfoundation in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-07-2015, 11:27 AM
  3. Replies: 4
    Last Post: 10-07-2015, 06:04 AM
  4. [SOLVED] How to apply correctly INDIRECT in SUMPRODUCT for 2 RANGES when 2 cell match
    By Franky alta in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 06-29-2015, 10:04 AM
  5. [SOLVED] Unit increase relative to variable unit thresholds
    By Fr3dle in forum Excel General
    Replies: 6
    Last Post: 07-01-2013, 06:57 AM
  6. Paste ranges with offset Excel 2000
    By carloshernandezy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-15-2005, 01:05 PM
  7. [SOLVED] E2003 naming ranges correctly
    By Estrelle71 in forum Excel General
    Replies: 1
    Last Post: 07-22-2005, 11: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