|
-
May 28th, 2008, 10:40 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] removing series from chart
Hey all,
I'm having one of those crazy problems where code worked for like 5 minutes, then after no changes, stops working.. ugh
Anyway.. pretty simple. Basically creating a chart, and want to get rid of the initial series that the chart comes with after creation. I have this exact code working in another part of my project, and this code worked fine for a little, then error message saying deletion of series failed.
vb Code:
Set chartLeach = Charts.Add
chartLeach.name = chartName
With chartLeach
If graphStyle = 2 Then
.ChartType = xlColumnClustered
ElseIf graphStyle = 1 Then
.ChartType = xlLine
End If
Do Until .SeriesCollection.count = 0
.SeriesCollection(1).Delete 'FAILING
Loop
End With
Is this bad practice? I'm baffled, especially after this exact code works in other spots of my project...
Thanks much!
-
May 28th, 2008, 11:00 AM
#2
Thread Starter
Hyperactive Member
Re: removing series from chart
hmm..
restarted the workbook and now it's working again... strange. I'll mark this as resolved, but if anyone has any comments on better practice it would be much appreciated!
Thanks
-
May 28th, 2008, 11:07 AM
#3
Re: [RESOLVED] removing series from chart
is that the complete code?
if yes, then the code never enters the if or the Do loop
To Check you can try this
Code:
Sub test()
Set chartLeach = Charts.Add
chartLeach.Name = chartname
With chartLeach
If graphStyle = 2 Then
.ChartType = xlColumnClustered
MsgBox "Entered the loop" '<===============
ElseIf graphStyle = 1 Then
.ChartType = xlLine
MsgBox "Entered the loop" '<===============
End If
Do Until .SeriesCollection.Count = 0
MsgBox "Entered the loop" '<===============
Loop
End With
End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 28th, 2008, 11:11 AM
#4
Thread Starter
Hyperactive Member
Re: [RESOLVED] removing series from chart
hmm.. yeah it's not the complete code. the graph style is defined earlier and it enters those ifs...
but there is something wierd about the .delete loop b/c it is actually entering it at some points and others not. I gotta do some more testing. b/c I changed from unloading that form to merely hiding it, and now I'm not encountering the problem.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|