Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default macro to delete all labels

hi,

anyone has a macro to delete all labels in a spreadsheet?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,104
Default macro to delete all labels


If by 'labels' you mean any text, then this will do it

Sub tryme()
For Each mycell In Application.ActiveSheet.UsedRange
If Application.WorksheetFunction.IsText(mycell) Then
mycell.Clear
End If
Next
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email


"Lynn" wrote in message
...
hi,

anyone has a macro to delete all labels in a spreadsheet?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default macro to delete all labels


Lynn,

Depends on what you mean by labels.... if all strings, then

Sub DeleteAllLabels()
Dim sh As Worksheet
For Each sh In Worksheets
sh.Cells.SpecialCells(xlCellTypeConstants, 2).Clear
Next sh
End Sub

HTH,
Bernie
MS Excel MVP


"Lynn" wrote in message
...
hi,

anyone has a macro to delete all labels in a spreadsheet?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default macro to delete all labels


If you mean comments then run this from each worksheet:-

Public Sub ClearLabels()
For Each c In ActiveSheet.Comments
c.Delete
Next
End Sub

If you want to do all sheets within the workbook then post back and I will
update.

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Lynn" wrote:

hi,

anyone has a macro to delete all labels in a spreadsheet?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default macro to delete all labels


If by "labels" you mean Label controls (from either the Forms toolbar or the
Control Toolbox toolbar), then read on.

Your question wasn't clear about whether you wanted every label on every
worksheet deleted or only the labels on a specific worksheet. Here is the
code for removing the labels from *all* worksheets...

Sub DeleteAllLabelControls()
Dim WS As Worksheet
Dim Lbl As OLEObject
For Each WS In Worksheets
WS.Labels.Delete
For Each Lbl In WS.OLEObjects
Lbl.Delete
Next
Next
End Sub

Here is how to remove them from a single worksheet (assumed to be named
Sheet1 for this example)...

Sub LabelControlsFromSheet1()
Dim Lbl As OLEObject
With Worksheets("Sheet1")
.Labels.Delete
For Each Lbl In .OLEObjects
Lbl.Delete
Next
End With
End Sub

--
Rick (MVP - Excel)


"Lynn" wrote in message
...
hi,

anyone has a macro to delete all labels in a spreadsheet?




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default macro to delete all labels

sorry, its called names.

Insert - names - define

How do i delete all names in a workbook. thanks
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default macro to delete all labels


Public Sub RemoveNames()
Dim n As Name
For Each n In ActiveWorkbook.Names
n.Delete
Next
End Sub

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Lynn" wrote:

sorry, its called names.

Insert - names - define

How do i delete all names in a workbook. thanks

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default macro to delete all labels


You might want to be careful when deleting *all* names since Excel uses
Names for some of the things it does (Print Area, Print Titles for example);
however, this code will delete *all* Names...

Sub deleteRanges()
Dim WBname As Name
For Each WBname In ActiveWorkbook.Names
WBname.Delete
Next
End Sub

--
Rick (MVP - Excel)


"Lynn" wrote in message
...
sorry, its called names.

Insert - names - define

How do i delete all names in a workbook. thanks


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default macro to delete all labels


That was not the best macro name I could have used<g (it was the name I had
on another routine; I just cleared out its code and wrote my new code in its
"housing"). Perhaps

Sub DeleteNames()

might be a better name to use.

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
You might want to be careful when deleting *all* names since Excel uses
Names for some of the things it does (Print Area, Print Titles for
example); however, this code will delete *all* Names...

Sub deleteRanges()
Dim WBname As Name
For Each WBname In ActiveWorkbook.Names
WBname.Delete
Next
End Sub

--
Rick (MVP - Excel)


"Lynn" wrote in message
...
sorry, its called names.

Insert - names - define

How do i delete all names in a workbook. thanks



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default macro to delete all labels


There are names that excel creates and uses. You may not want to delete them.

I'd get a copy of Jan Karel Pieterse's (with Charles Williams and Matthew
Henson) Name Manager:

You can find it at:
NameManager.Zip from http://www.oaltd.co.uk/mvp

You'll be able to delete the names you want and keep the names you're not sure
of.

Lynn wrote:

sorry, its called names.

Insert - names - define

How do i delete all names in a workbook. thanks


--

Dave Peterson
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
Delete all labels on a line chart Steve Mackay Excel Programming 1 April 10th 08 08:59 AM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:16 PM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:11 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:54 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM


All times are GMT +1. The time now is 01:11 AM.

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"