home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 10,686 of 10,840   
   Stratocaster to All   
   Re: Select Cells, and performing macro o   
   14 Nov 08 03:33:35   
   
   From: stotz1@verizon.net   
      
   Thanks for your input Alfie.  After spending some time with the help menu I   
   decided a reference guide might be in order (it was).  I did manage to write   
   a macro to loop through this graphing procedure.  For any wanderers that   
   might be out there, here is the macro (I don't like leaving my newsgroup   
   questions unanswered) assuming the raw data, not the labels, begin at Column   
   B and end at Column E):   
      
   Sub graphemups()   
       For Num = 2 To 8   
           Datastart = "B"   
           Dataend = "E"   
           Range("A" & Num).Activate   
           ActiveSheet.Shapes.AddChart.Select   
           ActiveChart.SetSourceData Source:=Range("1:1,10:10")   
           ActiveChart.ChartType = xlLineMarkers   
           ActiveChart.SeriesCollection.NewSeries   
           ActiveChart.SeriesCollection(2).Name = ActiveCell.Value   
           ActiveChart.SeriesCollection(2).Values = Range(Datastart & Num,   
   Dataend & Num)   
       Next Num   
   End Sub   
      
   The lesson I learned from this:  Chances are you can do ->what<- you want in   
   VBA but you may not be able to do it ->how<- you want.  I spent far to much   
   time trying to force a range variable in the Data Source expression and   
   overlooked simply adding a new series to a pre-existing graph.   
      
   There are some things I would like to have done with this macro still out of   
   my reach.  So if there are any VBA buffs scoffing at this code feel free to   
   also provide instruction on the following (in addition to any lashings):   
      
   It is probably noticeable that the SourceData extends throughout entire   
   rows:   
   ActiveChart.SetSourceData Source:=Range("1:1,10:10")   
      
   While the series I added does not:   
   ActiveChart.SeriesCollection(2).Values = Range(Datastart & Num, Dataend &   
   Num)   
      
   I had originally intended to set these graphs up so that they would   
   update/include any additional columns a user might add.  I found it was   
   possible to add an additional series containing an entire row of values   
   (i.e.):   
   ActiveChart.SeriesCollection(2).Values = ActiveCell.EntireRow   
      
   However, this also forces Excel to graph all empty columns and the result is   
   ugly.  So then, how could I perform this graphing loop so that future   
   updates would be recognized by these graphs?   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca