Hi,
in my pie chart macro I have the below code
Range("C45").Select
I will sometimes select different cell groups, but I don t want to change the cell ref. in the code everytime. How can I do it ?
regards,
Hi,
in my pie chart macro I have the below code
Range("C45").Select
I will sometimes select different cell groups, but I don t want to change the cell ref. in the code everytime. How can I do it ?
regards,
OSMAN
Use Selection as the range object instaed o the specific range.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Hi Xld,
I tried, but I get error, can you please help ?
Sub Makro1()
Range.Select
Charts.Add
ActiveChart.ChartType = xlPie
ActiveChart.SetSourceData Source:=Sheets("Sayfa1").Range.Select, PlotBy:= _
xlRows
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sayfa1"
ActiveChart.HasTitle = False
Application.CommandBars("Chart").Visible = False
ActiveChart.ApplyDataLabels AutoText:=True, LegendKey:=False, _
HasLeaderLines:=True, ShowSeriesName:=False, ShowCategoryName:=False, _
ShowValue:=True, ShowPercentage:=True, ShowBubbleSize:=False
End Sub
OSMAN
Hi aoc,
I believe what xld meant was something like this:
[vba]Sub Makro1()
Dim Range1 As range
Dim ws As Worksheet
Set Range1 = Selection
Set ws = ActiveSheet
Charts.Add
ActiveChart.ChartType = xlPie
ActiveChart.SetSourceData Source:=Range1, PlotBy:= _
xlRows
ActiveChart.Location Where:=xlLocationAsObject, Name:=ws.Name
ActiveChart.HasTitle = False
Application.CommandBars("Chart").Visible = False
ActiveChart.ApplyDataLabels AutoText:=True, LegendKey:=False, _
HasLeaderLines:=True, ShowSeriesName:=False, ShowCategoryName:=False, _
ShowValue:=True, ShowPercentage:=True, ShowBubbleSize:=False
End Sub[/vba]