Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove the middle data on a chart

Status
Not open for further replies.

Chance1234

IS-IT--Management
Jul 25, 2001
7,871
US
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




 
To answer my own question, slightly different approach but it works;

function funRemoveData(Wrksht as Worksheet, Xran as integer) ' xran is the number of rows in the data.

dim XranFirst, XranLast As Integer
Dim CntRow as integer



XranFirst = Round(Xran / 3, 0)

XranLast = Xran - (XranFirst)


While XranFirst + (Xran - XranLast) > 149 ' maximum rows allowed for printing

XranFirst = XranFirst - 1
XranLast = XranLast + 1

Wend


CntRow = XranFirst

Do Until CntRow = XranLast
Wrksht.Rows(CntRow).EntireRow.Hidden = True
CntRow = CntRow + 1
Loop

end function


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top