Closed Thread
Results 1 to 6 of 6

Select Cells by Style

  1. #1
    Werner Rohrmoser
    Guest

    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


  2. #2
    Gary''s Student
    Guest

    RE: 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
    >
    >


  3. #3
    Tom Ogilvy
    Guest

    RE: 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
    > >
    > >


  4. #4
    Gary''s Student
    Guest

    RE: 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
    > > >
    > > >


  5. #5
    Werner Rohrmoser
    Guest

    Re: 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


  6. #6
    Tom Ogilvy
    Guest

    Re: 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
    >
    >


Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1