Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 10th, 2012, 05:49 PM
Registered User
 
Join Date: Aug 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Changing chart axis title based on text in a cell

Hello, i'm fairly new to excel vba. I'm using excel 2010 and trying to change the label on the x axis of a chart based on text entered into a cell. Below is some of the code I have pieced together, but there is an error when I try to run the code:

Sub ChangeAxisTitle()
'X-Axis Title
Dim xaxis As axis
With ActiveChart
range("P37") = .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text
With .Axes(xlCategory)
.HasTitle = True
If ActiveSheet.range("$M$37").Text = "Title 1" Then
.AxisTitle.Characters.Text = "Time"
Else: .AxisTitle.Characters.Text = "Title 2"
End If
End With
End With
End Sub
 
Old August 19th, 2012, 10:46 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Can you please try ChartTitle.Text

http://vbadud.blogspot.in/2012/01/ho...art-using.html

I have used that in the above and it has worked for me'

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
[VB2005]adding second y-axis to chart bellaelysium VB How-To 2 June 17th, 2008 01:16 AM
Coloring the chart plot area based on x-axis scale simranjeev Reporting Services 1 October 25th, 2007 02:50 PM
Chart Axis label Colour dmunro Reporting Services 1 September 28th, 2006 03:30 PM
Problem in formating Y axis of Chart mayuri Crystal Reports 0 December 26th, 2005 08:15 AM
Adding a second value axis to chart..? rstober Excel VBA 0 October 1st, 2003 02:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.