Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Referencing cells and copy rows of data back to summary sheet | Excel Discussion (Misc queries) | |||
Referencing rows to columns | Excel Discussion (Misc queries) | |||
Referencing columns to rows | Excel Worksheet Functions | |||
Referencing columns as rows | Excel Discussion (Misc queries) | |||
Referencing increasing rows vertically. | Excel Worksheet Functions |