Solved

VB to select cells in excel

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
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.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

810 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