Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default parsing blocks of cells for charts

day 2 of VBA...

I've managed to create a worksheet ("Summary") containing blocks of
cells separated by empty rows. Now I'm struggling with the next bit.

In the first block, cell A1 contains the title of a chart, B1:Q5
contains the chart data. The other blocks are different sizes but with
the same basic layout.

I've also have a subroutine DoChrt for drawing a chart (see below).
What I would like to do now is to have a subroutine that takes each
block of data, identifies the chart title (always top left in the
block) and source data (variable size but same position relative to
title), makes the chart, then moves on to the next block.

I'd be very grateful if anyone has any ideas how to set this up.

Thanks
Simon


Sub DoChrt()
Dim Cht As Chart
Set Cht = Charts.Add
Cht.SetSourceData Source:=Sheets("Summary").Range("B1:Q5")
With Cht
.HasTitle = True
.ChartTitle.Characters.Text = Sheets("Summary").Range("A1")
End With
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default parsing blocks of cells for charts

Sub DoChrt()
Dim Cht As Chart
Dim rng As Range, ar As Range
Dim Data As Range, titlecell As Range
With Worksheets("Summary")
Set rng = .Columns(1).SpecialCells(xlConstants)
End With
For Each ar In rng.Areas
Set titlecell = ar(1)
Set Data = rng.Parent.Range(titlecell(2, 1), _
titlecell(2, 1).End(xlToRight).End(xlDown))
Set Cht = Charts.Add
Cht.SetSourceData Source:=Data
With Cht
.HasTitle = True
.ChartTitle.Characters.Text = titlecell
End With
Next
End Sub

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
day 2 of VBA...

I've managed to create a worksheet ("Summary") containing blocks of
cells separated by empty rows. Now I'm struggling with the next bit.

In the first block, cell A1 contains the title of a chart, B1:Q5
contains the chart data. The other blocks are different sizes but with
the same basic layout.

I've also have a subroutine DoChrt for drawing a chart (see below).
What I would like to do now is to have a subroutine that takes each
block of data, identifies the chart title (always top left in the
block) and source data (variable size but same position relative to
title), makes the chart, then moves on to the next block.

I'd be very grateful if anyone has any ideas how to set this up.

Thanks
Simon


Sub DoChrt()
Dim Cht As Chart
Set Cht = Charts.Add
Cht.SetSourceData Source:=Sheets("Summary").Range("B1:Q5")
With Cht
.HasTitle = True
.ChartTitle.Characters.Text = Sheets("Summary").Range("A1")
End With
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default parsing blocks of cells for charts

perfect - thanks very much

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
Stacked charts with separate blocks aburcubur Charts and Charting in Excel 1 March 31st 09 10:40 AM
Copying Blocks of Cells [email protected] Excel Discussion (Misc queries) 1 March 4th 09 11:54 AM
SUMIFs for particular cells in blocks of data [email protected] Excel Worksheet Functions 2 August 22nd 08 11:42 PM
Stop selecting blocks of cells Legallisa - switching from WordPerfect New Users to Excel 2 June 10th 08 03:04 AM
how to split address blocks across multiple cells JoannaF Excel Worksheet Functions 13 May 2nd 06 12:19 PM


All times are GMT +1. The time now is 06:58 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"