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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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
 
Upvote 0
there are many mistakes in the vbcodes. please explain what you want to do. somebody can give a soltion.
 
Upvote 0
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)
 
Upvote 0
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"
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,399
Members
448,957
Latest member
Hat4Life

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
Back
Top