Select Cells by Style
Hello,
I've nothing found in the Online Help and in the USENET related to this topic. Is there a standard command to select cells with the same style or do I have to code something similar to John Walkenbach's "select by format" tool. When I change a style I'd like to know which cells are affected, before I apply it. TIA Werner |
Select Cells by Style
Hi Werner:
Try this: Sub gsnu() Dim r1, r2 As Range For Each r1 In Selection If r1.Style = "Normal" Then If r2 Is Nothing Then Set r2 = r1 Else Set r2 = Union(r2, r1) End If End If Next If Not r2 Is Nothing Then r2.Select End If End Sub Select an area and run the macro. Substitute your style for "Normal" -- Gary''s Student "Werner Rohrmoser" wrote: Hello, I've nothing found in the Online Help and in the USENET related to this topic. Is there a standard command to select cells with the same style or do I have to code something similar to John Walkenbach's "select by format" tool. When I change a style I'd like to know which cells are affected, before I apply it. TIA Werner |
Select Cells by Style
You know that
Dim r1, r2 As Range is the same as Dim r1 as Variant, r2 as Range don't you. -- Regards, Tom Ogilvy "Gary''s Student" wrote: Hi Werner: Try this: Sub gsnu() Dim r1, r2 As Range For Each r1 In Selection If r1.Style = "Normal" Then If r2 Is Nothing Then Set r2 = r1 Else Set r2 = Union(r2, r1) End If End If Next If Not r2 Is Nothing Then r2.Select End If End Sub Select an area and run the macro. Substitute your style for "Normal" -- Gary''s Student "Werner Rohrmoser" wrote: Hello, I've nothing found in the Online Help and in the USENET related to this topic. Is there a standard command to select cells with the same style or do I have to code something similar to John Walkenbach's "select by format" tool. When I change a style I'd like to know which cells are affected, before I apply it. TIA Werner |
Select Cells by Style
Thank you Tom.
-- Gary''s Student "Tom Ogilvy" wrote: You know that Dim r1, r2 As Range is the same as Dim r1 as Variant, r2 as Range don't you. -- Regards, Tom Ogilvy "Gary''s Student" wrote: Hi Werner: Try this: Sub gsnu() Dim r1, r2 As Range For Each r1 In Selection If r1.Style = "Normal" Then If r2 Is Nothing Then Set r2 = r1 Else Set r2 = Union(r2, r1) End If End If Next If Not r2 Is Nothing Then r2.Select End If End Sub Select an area and run the macro. Substitute your style for "Normal" -- Gary''s Student "Werner Rohrmoser" wrote: Hello, I've nothing found in the Online Help and in the USENET related to this topic. Is there a standard command to select cells with the same style or do I have to code something similar to John Walkenbach's "select by format" tool. When I change a style I'd like to know which cells are affected, before I apply it. TIA Werner |
Select Cells by Style
Thanks for the replies,
there seems to be no standard command like "Edit" = "GoTo" = "Special" = "Formulas". So I'm going to use a procedure like described above to detect the cells with a specific style. Regards Werner |
Select Cells by Style
columns(3).specialcells(xlformulas).Select
would certainly do that - so not sure what you mean. -- Regards, Tom Ogilvy "Werner Rohrmoser" wrote: Thanks for the replies, there seems to be no standard command like "Edit" = "GoTo" = "Special" = "Formulas". So I'm going to use a procedure like described above to detect the cells with a specific style. Regards Werner |
All times are GMT +1. The time now is 10:54 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com