View Full Version : Solved: select
Hi,
in my pie chart macro I have the below code
Range("C4:D5").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,
Bob Phillips
01-30-2010, 02:30 AM
Use Selection as the range object instaed o the specific range.
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
markman123
01-30-2010, 03:13 PM
Hi aoc,
I believe what xld meant was something like this:
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
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.