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.
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 de calvuch
1