Returning the name of a deleted cell style

H

Harrison Tomlinson

The marco opens a new sheet and returns the name of the deleted styles
in the workbook of the new sheet. Or, it's suppose too. The problem is
that sometimes it will not return the name of the deleted styles to
the new sheet. The only reason for it doing this that I could come up
with is that the macro works in excel 2003 workbooks but not 2007
workbooks. This could be completely wrong, it is only a guess. The
code is as follows:

ActiveWorkbook.Sheets.Add Before:=Worksheets(1)
ActiveSheet.Name = "Deleted Styles"
DelCount = 0

For Each styT In ActiveWorkbook.Styles
If DelCount < 30000 Then
If styT.BuiltIn <> True Then
styT.Delete
Range("A1").Offset(DelCount).Select
Range("A1").Offset(DelCount).Value = styT.Value
DelCount = DelCount + 1

Else
End If
Else
Exit Sub
End If
Next styT

Any solutions would be appreciated. I believe the problem has
something to do with the "Range("A1").Offset(DelCount).Value =
styT.Value" but again, I could be wrong.

Thanks - HT
 
J

Jim Cone

I think you want the styT.Name not the styT.Value
Also, I would extract the name before deleting it.
A better bet for you, it appears, would be to use the free "Formats & Styles" add-in available
here...
http://excelusergroup.org/media/
It can generate a list of unused Styles or delete them.
--
Jim Cone
Portland, Oregon USA
http://www.mediafire.com/PrimitiveSoftware
(free and commercial excel programs)






"Harrison Tomlinson" <[email protected]>
wrote in message
news:3861f0ae-5c9b-4b99-9f73-fea39460e6e7@g16g2000yqg.googlegroups.com...
 
H

Harrison Tomlinson

I think you want the styT.Name not the styT.Value
Also, I would extract the name before deleting it.
A better bet for you, it appears, would be to use the free "Formats & Styles" add-in available
here...
 http://excelusergroup.org/media/
It can generate a list of unused Styles or delete them.
--
Jim Cone
Portland, Oregon USAhttp://www.mediafire.com/PrimitiveSoftware
(free and commercial excel programs)

"Harrison Tomlinson" <[email protected]>
wrote in message








- Show quoted text -

I changed the styT.Value to styT.Name and the same error was
occurring.

The Add-on would be my first choice but sadly, I can not add it. This
must be accomplished through an excel macro. Any other possible
solutions?

Thanks - HT
 
G

GS

Harrison Tomlinson explained :
I changed the styT.Value to styT.Name and the same error was
occurring.

The Add-on would be my first choice but sadly, I can not add it. This
must be accomplished through an excel macro. Any other possible
solutions?

Thanks - HT

Since add-ins contain macros, AND the add-in Jim suggested for you has
macros to meet your needs, is there some reason why you can't copy the
relevent macros from the add-in directly into your project?
 
J

Jim Cone

What about the other suggestion of mine: "Also, I would extract the name before deleting it"
'---
Jim Cone


"Harrison Tomlinson" <[email protected]>
wrote in messagenews:3861f0ae-5c9b-4b99-9f73-fea39460e6e7@g16g2000yqg.googlegroups.com...

I changed the styT.Value to styT.Name and the same error was
occurring.

The Add-on would be my first choice but sadly, I can not add it. This
must be accomplished through an excel macro. Any other possible
solutions?

Thanks - HT
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top