Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Check for the existence of data labels

Dear Experts:

below macro ...
.... deletes any data labels from all data series of all charts on the
active worksheet.

I wonder whether the macro could check at the beginning ...
.... for the existence of any data labels (1 to n) and if there are
none at all come up with a msgbox telling the user ('All data labels
have already been deleted!').

Help is much appreciated.Thank you very much in advance.

Regards, Andreas

Sub DataLabels_Remove()

Dim ChtObj As ChartObject
Dim i As Integer
Dim ser As Series
i = 0

For Each ChtObj In ActiveSheet.ChartObjects
With ChtObj.Chart
For Each ser In .SeriesCollection
ser.ApplyDataLabels (xlDataLabelsShowNone)
Next ser
End With
Next

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Check for the existence of data labels

Hi Andreas,

I am afraid a message before removing the labes will not be posible.
You could check if labels have been deleted with something like:

Sub DataLabels_Remove()
Dim ChtObj As ChartObject
Dim i As Integer
Dim ser As Series
i = 0
Dim hasLabels As Boolean

For Each ChtObj In ActiveSheet.ChartObjects
With ChtObj.Chart
For Each ser In .SeriesCollection
If ser.HasDataLabels Then
hasLabels = True
End If
ser.ApplyDataLabels (xlDataLabelsShowNone)
Next ser
End With
Next
If hasLabels = False Then
MsgBox "Labels already deleted"
End If
End Sub

HTH,

Wouter.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Check for the existence of data labels

On 7 Mrz., 22:24, Wouter HM wrote:
Hi Andreas,

I am afraid a message before removing the labes will not be posible.
You could check if labels have been deleted with something like:

Sub DataLabels_Remove()
* *Dim ChtObj As ChartObject
* *Dim i As Integer
* *Dim ser As Series
* *i = 0
* *Dim hasLabels As Boolean

* *For Each ChtObj In ActiveSheet.ChartObjects
* * * With ChtObj.Chart
* * * * *For Each ser In .SeriesCollection
* * * * * * If ser.HasDataLabels Then
* * * * * * * *hasLabels = True
* * * * * * End If
* * * * * * ser.ApplyDataLabels (xlDataLabelsShowNone)
* * * * *Next ser
* * * End With
* *Next
* *If hasLabels = False Then
* * * MsgBox "Labels already deleted"
* *End If
End Sub

HTH,

Wouter.


Hi Wouter,

great, thank you very much for your professional support. It is
working as desired.

Regards, Andreas
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Range existence check DoctorG Excel Programming 6 July 13th 06 04:31 PM
Check for existence CWillis Excel Discussion (Misc queries) 3 May 31st 06 01:20 PM
VBA to check for existence of a DSN GPO Excel Programming 2 May 29th 06 05:22 AM
How do I check for existence of a worksheet? LizzieHW Excel Worksheet Functions 1 July 19th 05 06:22 PM
Code to check existence No Name Excel Programming 2 November 4th 04 01:50 PM


All times are GMT +1. The time now is 07:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"