Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 3 of 3

Thread: select and group cells based on cell value

  1. #1
    Join Date
    13th February 2011
    Posts
    2

    select and group cells based on cell value

    Im trying to get a vba code that will enable me to look at the last cell in a column, says its value is 10. Then highlight the preceding lines based on the cell value and group them

    H15=10

    Highlight rows H16: H25 and then group

    Is there a VBA code for this. Ive been looking on the web all weekend with no real luck

    Thanks

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    26th July 2004
    Posts
    1,369

    Re: select and group cells based on cell value

    see if this helps

    VB:
    Sub example() 
        Set myrange = Sheets("sheet1").Range("H1", Range("H" & Rows.Count).End(xlUp)) 
        Set p = Sheets("sheet1").Cells(myrange(1, 1).Offset(myrange.Rows.Count - 1, 0).Row + 1, myrange(1, 1).Offset(myrange.Rows.Count - 1, 0).Column) 
        Set r = Sheets("sheet1").Cells(myrange(1, 1).Offset(myrange.Rows.Count - 1, 0).Row + myrange(1, 1).Offset(myrange.Rows.Count - 1, 0).Value + 1, myrange(1, 1).Offset(myrange.Rows.Count - 1, 0).Column) 
        myrange = p.Address & ":" & r.Address 
        Range(myrange).Select 
    End Sub 
    
    

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    13th February 2011
    Posts
    2

    Re: select and group cells based on cell value

    Thankyou so much. God I wish I had you skills.

    I just had to take out the value of 1 in Set r line of code and add in selection.rows.group as the last line and it works a treat.

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Select And Copy Cells Based On Values In Row
    By LeonS in forum EXCEL HELP
    Replies: 4
    Last Post: July 11th, 2007, 21:20
  2. Looking For A Cell In A Group Of Cells
    By joshlan in forum EXCEL HELP
    Replies: 5
    Last Post: January 30th, 2007, 05:05
  3. Select a Range based on a value in another two cells
    By barno_xvi in forum EXCEL HELP
    Replies: 5
    Last Post: July 31st, 2006, 21:03
  4. Changing mutual cell reference in a group of cells
    By Flusterphonic in forum EXCEL HELP
    Replies: 2
    Last Post: January 28th, 2006, 02:24
  5. Replies: 9
    Last Post: March 24th, 2003, 00:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
porno