Solved

VB to select cells in excel

Posted on 2011-02-23
3
225 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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
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 how to use a scrolling table in Microsoft Excel using the INDEX function.

839 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