Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JP JP is offline
external usenet poster
 
Posts: 103
Default Looping Range

I have a macro that sets the input data for several charts. I have a probelm
becuase it works for the first chart but then nothing happens. Let me guide
you through my code:

In one sub I give info on which tyoes of data that are to be used when
finding the input data for the charts.

If index = 0 Then
varWorksheetInfoArray(0) = "Avkdata"
varWorksheetInfoArray(1) = "Date"
call ChartMaker(varWorksheetInfoArray)
End if

if index =1....etc

Private Sub chartMaker(ByRef varWorksheetInfoArray() As Variant)
Dim i, j As Integer
Dim rng1, rng2, rng3, rng4, rng5, rng6, rng7 As Range

Set rng1 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(1),
LookIn:=xlValues)
Set rng2 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(2),
LookIn:=xlValues)
etc.
I then make some loops to find start and end values for the input data.

I then proceed to set the actual data for the chart:

Sheets("Rapport").Select
ActiveSheet.ChartObjects(varWorksheetInfoArray(10) ).Activate
ActiveChart.Axes(xlCategory).Select
With ActiveChart
..SeriesCollection(1).XValues =
Sheets(varWorksheetInfoArray(0)).Range(rng1.Offset (i, 0).Address & ":" &
rng1.Offset(j, 0).Address)
End With
'sätter x-axel

With ActiveChart
If Not rng2 Is Nothing Then
..SeriesCollection(1).Values =
Sheets(varWorksheetInfoArray(0)).Range(rng2.Offset (i, 0).Address & ":" &
rng2.Offset(j, 0).Address)
Else: End If

If Not rng3 Is Nothing Then
..SeriesCollection(2).Values =
Sheets(varWorksheetInfoArray(0)).Range(rng3.Offset (i, 0).Address & ":" &
rng3.Offset(j, 0).Address)
Else: End If

Now this works fine the first loop in my program i.e. when index = 0. I
think that the problem is in the:

If Not rng3 Is Nothing Then
........

But I cannot figure out what it is. I am very bad at vba so if you have any
idea and you are able to point in any direction I would be very greatful!!
Thank you all for invaluable assistance!
_________________

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping in a range Robert Excel Programming 3 April 24th 06 06:09 AM
Looping through a range Shawn[_10_] Excel Programming 2 October 3rd 05 08:51 PM
Looping through range names Craig Excel Programming 4 September 16th 05 05:20 AM
Looping through a range of cells Conan Kelly Excel Programming 2 August 18th 05 11:15 PM
looping through a range Jo[_6_] Excel Programming 1 October 21st 03 11:11 PM


All times are GMT +1. The time now is 06:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"