Consulting

Results 1 to 4 of 4

Thread: Solved: select

  1. #1
    VBAX Regular aoc's Avatar
    Joined
    Apr 2007
    Location
    Istanbul
    Posts
    90
    Location

    Solved: select

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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

  3. #3
    VBAX Regular aoc's Avatar
    Joined
    Apr 2007
    Location
    Istanbul
    Posts
    90
    Location
    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

  4. #4
    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]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •