?
Solved

VB to select cells in excel

Posted on 2011-02-23
3
Medium Priority
?
228 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 1200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
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…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

752 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