Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7035523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:18:51+00:00 2026-05-28T01:18:51+00:00

I recorded a macro to create graphs on a worksheet. The data are organized

  • 0

I recorded a macro to create graphs on a worksheet.
The data are organized in the same way in all the sheets of the workbook, therefore I would like to generalize the macro so that it can be used on every sheet (or if it is possible to batch through the worksheets).

The code looks like this:

ActiveWindow.SmallScroll Down:=-57
Range("C5:C65").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Range("fr_1!$C$5:$C$65")
ActiveChart.Axes(xlCategory).Select
ActiveChart.SeriesCollection(1).XValues = "=fr_1!$A$5:$A$65"

Having recorded the macro on fr_1 I now have that reference in the 5th and last line, while I would like to have a general reference to the active sheet.

How do I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:18:52+00:00Added an answer on May 28, 2026 at 1:18 am

    You can:

    Dim aSheet As Worksheet
    For Each aSheet In ActiveWorkbook.Worksheets
        With aSheet.Shapes.AddChart.Chart
            .ChartType = xlLine
            .SetSourceData Source:=aSheet.Range(aSheet.Name & "!$C$5:$C$65")
            .SeriesCollection(1).XValues = "=" & aSheet.Name & "!$A$5:$A$65"
        End With
    Next
    

    If you want to iterate the manually selected sheets change to for each asheet in activewindow.selectedsheets

    To manually filter by name;

    Dim aSheet As Worksheet
    For Each aSheet In ActiveWorkbook.Worksheets
        select case aSheet.name
            case "sheet1", "sheet50", "sheet999"   
                With aSheet.Shapes.AddChart.Chart
                    .ChartType = xlLine
                    .SetSourceData Source:=aSheet.Range(aSheet.Name & "!$C$5:$C$65")
                    .SeriesCollection(1).XValues = "=" & aSheet.Name & "!$A$5:$A$65"
                End With
        end select
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given: I recorded a simple macro in Openoffice to save my worksheet as a
I have a file with a bunch of lines. I have recorded a macro
I recorded a script using the Selenium IDE extension for Firefox, and I would
I recorded a macro to print an excel sheet when the button is pressed.
If I have a recorded audio file (MP3), is there any way to get
Suppose that I have recorded a long macro with many commands and special characters.
I've recorded a simple macro that I need to make into something generic, so
i'd like to write a macro that selects the next word to the right
I recorded some audio files, stored them in sdcard. I need to combine all
I'm budiling an application and it lists all the videos i recorded using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.