Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Rango variable en un gráfico

publicado

Hola,

El problema es el siguiente:

Si hago el gráfico como a continuación me funciona:

i = 0

Charts.Add

ActiveChart.ChartType = xlColumnClustered

ActiveChart.SetSourceData Source:=Sheets("DC").Range("H15000")

ActiveChart.SeriesCollection.NewSeries

ActiveChart.SeriesCollection(1).XValues = "=DC!R1C3:R168C4"

ActiveChart.SeriesCollection(1).Values = "=DC!R1C5:R168C5"

ActiveChart.SeriesCollection(1).Name = "=""DISOLVENTE CONSUMIDO"""

ActiveChart.Location Where:=xlLocationAsNewSheet

With ActiveChart

.HasTitle = True

.ChartTitle.Characters.Text = "DISOLVENTE CONSUMIDO"

.Axes(xlCategory, xlPrimary).HasTitle = True

.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "HORAS"

.Axes(xlValue, xlPrimary).HasTitle = True

.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "KG"

End With

With ActiveChart.Axes(xlCategory)

.HasMajorGridlines = False

.HasMinorGridlines = False

End With

With ActiveChart.Axes(xlValue)

.HasMajorGridlines = True

.HasMinorGridlines = False

End With

ActiveChart.HasLegend = False

ActiveChart.PlotArea.Select

With Selection.Border

.Weight = xlThin

.LineStyle = xlNone

End With

With Selection.Interior

.ColorIndex = 2

.PatternColorIndex = 1

.Pattern = xlSolid

End With

ActiveChart.ChartArea.Select

ActiveChart.Axes(xlCategory).Select

With Selection.Border

.Weight = xlHairline

.LineStyle = xlAutomatic

End With

With Selection

.MajorTickMark = xlNone

.MinorTickMark = xlNone

.TickLabelPosition = xlNextToAxis

End With

ActiveChart.ChartArea.Select

Pero si quiero que los datos con que quiero hacer las gráficas sean variables (como a continuación) tengo un problema en el código que no se como solventar:

i = 0

Charts.Add

ActiveChart.ChartType = xlColumnClustered

ActiveChart.SetSourceData Source:=Sheets("DC").Range("H15000")

ActiveChart.SeriesCollection.NewSeries

ActiveChart.SeriesCollection(1).XValues = "=DC!R(1+168*i)C3:R(168+168*i)C4"

ActiveChart.SeriesCollection(1).Values = "=DC!R(1+168*i)C5:R(168+168*i)C5"

ActiveChart.SeriesCollection(1).Name = "=""DISOLVENTE CONSUMIDO"""

ActiveChart.Location Where:=xlLocationAsNewSheet

With ActiveChart

.HasTitle = True

.ChartTitle.Characters.Text = "DISOLVENTE CONSUMIDO"

.Axes(xlCategory, xlPrimary).HasTitle = True

.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "HORAS"

.Axes(xlValue, xlPrimary).HasTitle = True

.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "KG"

End With

With ActiveChart.Axes(xlCategory)

.HasMajorGridlines = False

.HasMinorGridlines = False

End With

With ActiveChart.Axes(xlValue)

.HasMajorGridlines = True

.HasMinorGridlines = False

End With

ActiveChart.HasLegend = False

ActiveChart.PlotArea.Select

With Selection.Border

.Weight = xlThin

.LineStyle = xlNone

End With

With Selection.Interior

.ColorIndex = 2

.PatternColorIndex = 1

.Pattern = xlSolid

End With

ActiveChart.ChartArea.Select

ActiveChart.Axes(xlCategory).Select

With Selection.Border

.Weight = xlHairline

.LineStyle = xlAutomatic

End With

With Selection

.MajorTickMark = xlNone

.MinorTickMark = xlNone

.TickLabelPosition = xlNextToAxis

End With

ActiveChart.ChartArea.Select

Les agradecería mucho que me ayudasen con este problema, gracias.

Featured Replies

publicado

Hola jramia

Bienvenido al foro (¿Has leído las normas?, un archivo siempre ayuda a que te ayuden)

ActiveChart.SeriesCollection(1).XValues = "=DC!R(1+168*i)C3:R(168+168*i)C4"

ActiveChart.SeriesCollection(1).Values = "=DC!R(1+168*i)C5:R(168+168*i)C5"

Todo lo que va entre comillas será considerado como un texto y por lo tanto es lógico que no te funcione, deberías probar a separar la cadena en algo tal que

ActiveChart.SeriesCollection(1).XValues = "=DC!R(" & 1+168*i & ")C3:R(" & 168+168*i & ")C4"

ActiveChart.SeriesCollection(1).Values = "=DC!R(" & 1+168*i & ")C5:R(" & 168+168*i & ")C5"

no sé si te funcionará (si hubieras subido el archivo se podría haber probado) pero algo así debería valerte.

Un saludo desde Vitoria

  • Enigma25 bloqueó este tema

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.