+ Reply to Thread
Results 1 to 2 of 2

Looping Macro to Re-label X Axis on Graphs

  1. #1
    Registered User
    Join Date
    New York
    MS-Off Ver
    Excel 2010

    Looping Macro to Re-label X Axis on Graphs

    Good afternoon everyone,

    I have the following code below which I am using to re-label the X axis on several graphs:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target = Range("A1") Or Target = Range("B1") Then
    ActiveSheet.ChartObjects("Chart 1").Activate
    With ActiveChart.Axes(xlCategory)
    If Range("A1").Value <> "" Then .MinimumScale = Range("A1").Value
    If Range("B1").Value <> "" Then .MaximumScale = Range("B1").Value
    End With
    End If
    End Sub

    My problem is that this works for re-labeling the first graph but I am not experienced enough with VBA to figure out how to loop the macro for multiple graphs. Just as a heads up, I have "A1" set to 0 for the start of my X axis and "B1" is a count from another page so when additional data is added the count will increase.

    Any help would be much appreciated.


    Last edited by kanect; 07-07-2015 at 10:26 AM.

  2. #2
    Forum Guru
    Join Date
    Los Angeles, Ca
    MS-Off Ver

    Re: Looping Macro to Re-label X Axis on Graphs

    Please Login or Register  to view this content.
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. With a move label macro, prevent label from moving onto another label
    By SocratesJC in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-09-2014, 12:34 AM
  2. Looping through label controls
    By anthony1312002 in forum Excel General
    Replies: 2
    Last Post: 02-03-2012, 03:20 PM
  3. Scatter graphs - How do you label points?
    By nickbarthram in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-05-2007, 02:06 PM
  4. [SOLVED] Increasing X-axis Offset for graphs cutting x-axis
    By Hari Prasadh in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 08-23-2005, 05:05 AM
  5. Replies: 2
    Last Post: 08-12-2005, 08:05 AM


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