28. maj 2020 - 17:56Der er
3 kommentarer og 2 løsninger
Makro i Excel diagram
Er det muligt at oprette en makro i et diagram, der har til opgave at ændre minimums værdien for den lodrette akseindstilling.
Jeg har brug for skiftevis at kunne indsætte/udskifte minimumsværdierne til nedenstående værdier: 60 70 80 90 100 Dette for at undgå, at diagrammet automatisk viser fra 0 (nul) og opefter når der indtastes værdier, og man ikke har sat et minimumsværdi.
Er det noget i denne stil du er ude efter? Hver gang makroen aktiveres skifter min. værdien.
Sub Macro1() ActiveSheet.ChartObjects("Chart 1").Activate ActiveChart.Axes(xlValue).Select If ActiveChart.Axes(xlValue).MinimumScale = 50 Then ActiveChart.Axes(xlValue).MinimumScale = 60 Else If ActiveChart.Axes(xlValue).MinimumScale = 60 Then ActiveChart.Axes(xlValue).MinimumScale = 70 Else If ActiveChart.Axes(xlValue).MinimumScale = 70 Then ActiveChart.Axes(xlValue).MinimumScale = 80 Else If ActiveChart.Axes(xlValue).MinimumScale = 80 Then ActiveChart.Axes(xlValue).MinimumScale = 90 Else If ActiveChart.Axes(xlValue).MinimumScale = 90 Then ActiveChart.Axes(xlValue).MinimumScale = 100 Else If ActiveChart.Axes(xlValue).MinimumScale = 100 Then ActiveChart.Axes(xlValue).MinimumScale = 50 End If End If End If End If End If End If Application.CommandBars("Format Object").Visible = False Range("A1").Select
Hvis jeg kan få din løsning til at fungere vil det være rigtig fint. Jeg havde selv tænkt på at koble en Makro til en Knap for hver værdi. Jeg kan se nu, at jeg skulle have vendt talrækken om, med det største tal først. Jeg ser på det.
Jeg har nu fået det til at fungere. Jeg har vendt talrækken om. Starter fra 100 og går trinvis 5 ned til 55. Jeg har koblet en knap til Makroen. Dog kan jeg ikke få det til at fungere, hvis jeg tilføjer følgende linier fra dit forslag:
If ActiveChart.Axes(xlValue).MinimumScale > 100 Then ActiveChart.Axes(xlValue).MinimumScale = 100 Else If ActiveChart.Axes(xlValue).MinimumScale = 100 Then ActiveChart.Axes(xlValue).MinimumScale = 95 Else If ActiveChart.Axes(xlValue).MinimumScale = 95 Then ActiveChart.Axes(xlValue).MinimumScale = 90 Else If ActiveChart.Axes(xlValue).MinimumScale = 90 Then ActiveChart.Axes(xlValue).MinimumScale = 85 Else If ActiveChart.Axes(xlValue).MinimumScale = 85 Then ActiveChart.Axes(xlValue).MinimumScale = 80 Else If ActiveChart.Axes(xlValue).MinimumScale = 80 Then ActiveChart.Axes(xlValue).MinimumScale = 75 Else If ActiveChart.Axes(xlValue).MinimumScale = 75 Then ActiveChart.Axes(xlValue).MinimumScale = 70 Else If ActiveChart.Axes(xlValue).MinimumScale = 70 Then ActiveChart.Axes(xlValue).MinimumScale = 65 Else If ActiveChart.Axes(xlValue).MinimumScale = 65 Then ActiveChart.Axes(xlValue).MinimumScale = 60 Else If ActiveChart.Axes(xlValue).MinimumScale = 60 Then ActiveChart.Axes(xlValue).MinimumScale = 55 Else If ActiveChart.Axes(xlValue).MinimumScale = 55 Then ActiveChart.Axes(xlValue).MinimumScale = 100
End If End If End If End If End If End If End If End If End If End If End If
Det var vist et par koder der kom ind ved en fejl. De skal blot udelades
Synes godt om
1 synes godt om dette
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.