multiple plots with Chart Range

Preye

New Member
Joined
Jul 22, 2007
Messages
3
Hi,
I'm new to Excel VBA, and just wrote a code (see below) to help me plot multiple plots from a number of ranges in a sheet, but it doesn't seem to work.
Regards,

Code:
Sub Macro2()

    
    Dim TopOld As Integer, TopNew As Integer, Bottom As Integer
          
    
    TopOld = 16360
    
    For i = 16360 To 31477
    
        
        If Sheets("Sheet1").Cells(i, 1) <> Sheets("Sheet1").Cells(i + 1, 1) Then
            
        
            TopNew = i + 1
            Bottom = i
            
           Charts.Add
           ActiveChart.ChartType = xlLineMarkers
              
           rangeC = "C" & TopOld & ":" & "C" & Bottom
           rangeO = "O" & TopOld & ":" & "O" & Bottom
           
           
           ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("rangeC"), _
           PlotBy:=xlColumns
           
           ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R" & TopOld & "C3:R" & Bottom & "C3"
           
           ActiveChart.SeriesCollection(1).Values = "=Sheet1!R" & TopOld & "C15:R" & Bottom & "C15"
         
           ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
        
            
        End If
        TopOld = TopNew
                
    Next i
         
       
         
         
         
End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

ravishankar

Well-known Member
Joined
Feb 23, 2006
Messages
3,566
Hi
you want to plot Col C and col R and col O Values of a group of items. Is that right? Can you explain in simple terms what you want to achieve?
Ravi
 

venkat1926

Well-known Member
Joined
Aug 21, 2005
Messages
4,824
there are many mistakes in the vbcodes. please explain what you want to do. somebody can give a soltion.
 

Preye

New Member
Joined
Jul 22, 2007
Messages
3
Re: Multiple PLots with Chart Range

I intend plotting Col C as category, Col O and N as values. However, Col A Cell(i,1) has the row selection criteria for picking the row range to be plotted. Col A, has about 100 different sequential items starting from Cells(16360,i) to Cells(31477,1)
 

Preye

New Member
Joined
Jul 22, 2007
Messages
3
I intend plotting Col C as category, Col O and N as values. However, Col A Cell(i,1) has the row selection criteria for picking the row range of Col C, Col O and Col N to be plotted. Col A, has about 100 different sequentially arranged items starting from Cells(16360,1) to Cells(31477,1). The If statement is for picking the data range with "TopOld" start of row selection, "Bottom" end of row selection. So, its essentially picking the row range within the bounds of "TopOld" to "Bottom"
 

Forum statistics

Threads
1,181,717
Messages
5,931,646
Members
436,796
Latest member
parthibanmuniswamy

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
Top