Chance1234
IS-IT--Management
Its probably because ive been at my desk, since some unearthly hour in the morning, but i cant quite get my head around this, what i want to do is remove the middle data from a chart in excel, now the chart has been created from another program so i cant do much at source, but this is the path im going down
function funRemoveData(Wrksht as Worksheet, Xran as integer) ' xran is the number of rows in the data.
Dim XranFirst,Xranlast as integer ' the first & second range
Dim StrRan1, StrRan2 As String ' Strings for new ranges
XranFirst = Round(Xran / 3, 0)
XranLast = Xran - (XranFirst)
Debug.Print XranFirst & " " & XranLast
StrRan1 = "A1:B" & XranFirst
StrRan2 = "A" & XranLast & ":B" & Xran
Debug.Print StrRan1 & " " & StrRan2
With Wrksht.ChartObjects(1)
.Chart.SetSourceData = Source:= wrksht.range(StrRan1 & "," & StrRan2)
End With
as you can see it doesnt work! where am i goign wrong
function funRemoveData(Wrksht as Worksheet, Xran as integer) ' xran is the number of rows in the data.
Dim XranFirst,Xranlast as integer ' the first & second range
Dim StrRan1, StrRan2 As String ' Strings for new ranges
XranFirst = Round(Xran / 3, 0)
XranLast = Xran - (XranFirst)
Debug.Print XranFirst & " " & XranLast
StrRan1 = "A1:B" & XranFirst
StrRan2 = "A" & XranLast & ":B" & Xran
Debug.Print StrRan1 & " " & StrRan2
With Wrksht.ChartObjects(1)
.Chart.SetSourceData = Source:= wrksht.range(StrRan1 & "," & StrRan2)
End With
as you can see it doesnt work! where am i goign wrong