Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default referencing only rows with data

i'm new to macros(cursor only), and i want it to create and print a graph for
each row of data(about 25 columns wide). If I select the first row, how can i
have the macro keep selecting until the last row of data? Thank you, Rich
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default referencing only rows with data

First, it is not recommended using select. The macro recorder uses it but I
normally rewrite recorded macro not using the select. You need to select
chart which I consider a bug in VBA.


Here is recorded macro

Sub Macro1()
'
' Macro1 Macro
'

'
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Sheet1'!$A$4:$N$4")
ActiveChart.ChartType = xlXYScatterSmooth
End Sub


Here is my modified macro

Sub AddCharts()

With ActiveSheet
RowCount = 1
Do While .Range("A" & RowCount) < ""
LastCol = .Cells(RowCount, Columns.Count).End(xlToLeft).Column
Set ChartRange = .Range(.Range("A" & RowCount), .Cells(RowCount, LastCol))

Set MyChart = .Shapes.AddChart
MyChart.Select
With ActiveChart

.SetSourceData Source:=ChartRange
.ChartType = xlXYScatterSmooth
End With
RowCount = RowCount + 1
Loop
End With
End Sub

:

i'm new to macros(cursor only), and i want it to create and print a graph for
each row of data(about 25 columns wide). If I select the first row, how can i
have the macro keep selecting until the last row of data? Thank you, Rich

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default referencing only rows with data

Thanks Joel. This may be a step or two ahead of my current macro ability but
gives me a chance to take it to the next level !!

"Joel" wrote:

First, it is not recommended using select. The macro recorder uses it but I
normally rewrite recorded macro not using the select. You need to select
chart which I consider a bug in VBA.


Here is recorded macro

Sub Macro1()
'
' Macro1 Macro
'

'
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Sheet1'!$A$4:$N$4")
ActiveChart.ChartType = xlXYScatterSmooth
End Sub


Here is my modified macro

Sub AddCharts()

With ActiveSheet
RowCount = 1
Do While .Range("A" & RowCount) < ""
LastCol = .Cells(RowCount, Columns.Count).End(xlToLeft).Column
Set ChartRange = .Range(.Range("A" & RowCount), .Cells(RowCount, LastCol))

Set MyChart = .Shapes.AddChart
MyChart.Select
With ActiveChart

.SetSourceData Source:=ChartRange
.ChartType = xlXYScatterSmooth
End With
RowCount = RowCount + 1
Loop
End With
End Sub

:

i'm new to macros(cursor only), and i want it to create and print a graph for
each row of data(about 25 columns wide). If I select the first row, how can i
have the macro keep selecting until the last row of data? Thank you, Rich

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
Referencing cells and copy rows of data back to summary sheet MaggieR Excel Discussion (Misc queries) 5 October 16th 07 11:41 PM
Referencing rows to columns [email protected] Excel Discussion (Misc queries) 3 October 12th 07 12:55 AM
Referencing columns to rows Deba Excel Worksheet Functions 8 May 14th 06 12:07 PM
Referencing columns as rows bob135 Excel Discussion (Misc queries) 8 April 13th 06 01:22 PM
Referencing increasing rows vertically. Rosebud Computing Excel Worksheet Functions 0 January 28th 05 05:59 AM


All times are GMT +1. The time now is 10:35 AM.

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"