+ Reply to Thread
Results 1 to 2 of 2

Need help with Macro to run on activated sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    04-17-2008
    Posts
    1

    Need help with Macro to run on activated sheet

    Hi All,

    I have a workbook with multiple sheets that have similar data on similar fields. I recorded the macro on sheet 1 "ref", but does not run on any other sheets. How can I change it so that it runs on ANY sheet that's active.

    thanks,

    sjsfiji

    ---------------------

    Sub Macro12()
    '
    ' Macro12 Macro
    ' Macro recorded 4/17/2008 by andrew.carino
    '
    ' Keyboard Shortcut: Ctrl+k
    '
        Charts.Add
        ActiveChart.ApplyCustomType ChartType:=xlUserDefined, TypeName:="Gantt"
        ActiveChart.SetSourceData Source:=Sheets("Ref").Range("A1:G15"), PlotBy:= _
            xlColumns
        ActiveChart.SeriesCollection(2).Delete
        ActiveChart.SeriesCollection(2).Delete
        ActiveChart.SeriesCollection(4).Delete
        ActiveChart.Location Where:=xlLocationAsObject, Name:="Ref"
    End Sub
    Last edited by rylo; 04-17-2008 at 07:42 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Try this

    Charts.Add
    ActiveChart.ApplyCustomType ChartType:=xlUserDefined, TypeName:="Gantt"
    ActiveChart.SetSourceData Source:=Sheets(ActiveSheet.Name).Range("A1:G15"), PlotBy:= _
    xlColumns
    ActiveChart.SeriesCollection(2).Delete
    ActiveChart.SeriesCollection(2).Delete
    ActiveChart.SeriesCollection(4).Delete
    ActiveChart.Location Where:=xlLocationAsObject, Name:=ActiveSheet.Name
    Can you please remember to wrap your code in future posts. Highlight your code, then press the # icon and this will perform the wrap.

    rylo

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1