Insertar Fecha en gráfico, Macro

Buenas, tengo un problema al insertar la fecha en el titulo de un gráfico. El problema es el siguiente, tengo un macro que me hace un gráfico y cuando intento ingresar una fecha en el titulo como "Feb-2011" automáticamente me la cambia a "01/02/2011", estuve buscando soluciones parecidas pero no encuentro la solución.
Sub GRAFICO()
Dim FechaPrima As String
Dim FechaUltima As String
FechaPrima = Sheets("Hoja2").Range("A1").Value
FechaUltima = Sheets("Hoja2").Range("B1").Value
Sheets("Hoja2").Select
'GRAFICO 1, VARIACIÓN PRECIO POR UNIDAD PERIODO
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = _
"=(Hoja2!R1C1,Hoja2!R75C1,Hoja2!R149C1,Hoja2!R223C1,Hoja2!R297C1,Hoja2!R371C1)"
ActiveChart.SeriesCollection(1).Values = _
"=(Hoja2!R73C5,Hoja2!R147C5,Hoja2!R221C5,Hoja2!R295C5,Hoja2!R369C5,Hoja2!R443C5)"
ActiveChart.SeriesCollection(1).Name = "=""Livianos"""
ActiveChart.SeriesCollection(2).Values = _
"=(Hoja2!R73C6,Hoja2!R147C6,Hoja2!R221C6,Hoja2!R295C6,Hoja2!R369C6,Hoja2!R443C6)"
ActiveChart.SeriesCollection(2).Name = "=""Grandes"""
ActiveChart.SeriesCollection(3).Values = _
"=(Hoja2!R75C6,Hoja2!R149C6,Hoja2!R223C6,Hoja2!R297C6,Hoja2!R371C6,Hoja2!R445C6)"
ActiveChart.SeriesCollection(3).Name = "=""Promedio"""
ActiveChart.Location Where:=xlLocationAsObject, Name:="Hoja1"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "VARIACION PRECIO POR UNIDAD PERIODO " & FechaPrima & " Al " & FechaUltima
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveChart.HasLegend = False
ActiveChart.HasDataTable = True
ActiveChart.DataTable.ShowLegendKey = True
ActiveChart.Axes(xlValue).Select
ActiveChart.PlotArea.Select
ActiveChart.ApplyDataLabels ShowValue:=True
With ActiveChart.Axes(xlValue)
.MinimumScale = 130
.MaximumScale = 230
.MinorUnitIsAuto = True
.MajorUnit = 25
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
n = Len("Hoja1")
x = Mid(ActiveChart.Name, n + 2, 20)
ActiveSheet.Shapes(x).IncrementLeft -245
ActiveSheet.Shapes(x).IncrementTop -102.75
ActiveSheet.Shapes(x).ScaleHeight 1.3, msoFalse, _
msoScaleFromTopLeft
Saludos.

1 Respuesta

Respuesta
1
Eso sucede por que debes modificar el formato de la celda que contiene la fecha, dale el formato de "Texto" ya que tu macro solo hace referencia a "ubicaciones" y no a tipo de dato, entonces excel lo toma como Fecha a menos que le digas que es Texto.
Hola.
Me pasa lo siguiente, cuando cambio el formato a texto me lo cambia por un número.
Saludos.
prueba esto ( quítale el .value)
FechaPrima = Sheets("Hoja2").Range("A1")
FechaUltima = Sheets("Hoja2").Range("B1")
O lo otro:
Prueba lo siguiente: al añadir el titulo antepone un cracter "Vacio", lo puedes hacer directo en la celda ( presiona espacio y luego añade el texto) o vía código
O bien:
FechaPrima = " " & Sheets("Hoja2").Range("A1")
FechaUltima = " " & Sheets("Hoja2").Range("B1")
Si no resulta alguna de estas opciones, la verdad no se que más puede ser

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas