Solved

VB to select cells in excel

Posted on 2011-02-23
3
223 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
Comment Utility
Try:

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


Chris
0
 
LVL 8

Expert Comment

by:pdd1lan
Comment Utility
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
Comment Utility
works great! thanks
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now