Diagram lavet med vba problem
Hejsahmmm, følgende kode laver et forkert diagram, mon der er en der kan knække den?
Option Explicit
Dim WsDiagram As Worksheet, wsBeregn As Worksheet
Dim StartCell As Range, Area As Range, Cell As Range
Dim LastRow As Integer
Dim rng As Range
Dim Top As Integer, Left As Integer
Const Width As Integer = 500, Height As Integer = 200
Dim Cht As Object
Sub MakeDiagram()
Set WsDiagram = Sheets("Diagram")
Set wsBeregn = Sheets("Beregn")
Set StartCell = WsDiagram.Range("B3")
Set Area = wsBeregn.Range("H3:H7")
Left = StartCell.Left
Top = StartCell.Top
For Each Cell In Area
If Cell.Value = "" Then
LastRow = Cell.Row - 1
Else
LastRow = Cell.Row
End If
Next
Set rng = Range("Beregn!H2:T" & LastRow)
Set Cht = WsDiagram.Shapes.AddChart2
With Cht
.Left = Left
.Top = Top
.Width = Width
.Height = Height
With .Chart
.SetSourceData Source:=rng
.ChartType = xlColumnClustered
End With
End With
End Sub
nedenstående viser problemet
https://www.dropbox.com/s/f0cwo30nz0mm9h6/Diagram.docx?dl=0
Jan