Solved

VB to select cells in excel

Posted on 2011-02-23
3
227 Views
Last Modified: 2012-05-11
The current code finds the first "o" in a column, then selects all values below (by CTRL+SHIFT+Down) ... but right now, it selects all values below the first "o" found, including the "Total" row. I need everthing selected once the "o" is found, except the "Total" row.

Its really a matter of doing the (by CTRL+SHIFT+Down) action, except the last row but im not sure how to do it. See the file attached and code.

Hopes this makes some sense. Let me know if any further questions.

Any takers?

Sub FindGroup()
    Cells.Find(What:="o", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
        xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Rows.Group
End Sub

Open in new window

EE-Sample.xls
0
Comment
Question by:ctownsen80
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 300 total points
ID: 34960520
Try:

Range(Selection, Selection.End(xlDown)).offset(-1,0).select


Chris
0
 
LVL 8

Expert Comment

by:pdd1lan
ID: 34960544
have to try it yet:

Sub FindGroup()

   If ActiveCell <> "Total" Then

    Cells.Find(What:="o", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
        xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Rows.Group

end if

End Sub
0
 

Author Closing Comment

by:ctownsen80
ID: 34960559
works great! thanks
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question