PDA

View Full Version : VBC to highlight / select group of active cell



merndogg
08-04-2014, 09:22 AM
Hello! I am a newb so unfortunately I don't have any code to post here but I am looking for code that will delete the group of an active cell. So, if I select cell B5 for instance, and it is in a single tired group (fyi, all groups are single tiered - no multi tiered groups will be used) then it will highlight that specific group that cell B5 falls within and delete the entire group. FYI, I am not using group names for my groups.

Any help would be greatly appreciated.

Thanks,
Marion

Bob Phillips
08-04-2014, 11:22 AM
Not very clear, but maybe


Activecell.CurrentRegion.ClearContents

merndogg
08-04-2014, 01:49 PM
Thank you. When I run that macro it selects the current region and clears the contents naturally. I am wanting to highlight the current region and delete the entire group of rows in that outline. I modified the code as follows:
ActiveCell.CurrentRegion.EntireRow.Delete

This kind of worked. It deleted the entire group if you first selected a cell with data in it before running the macro. But if you if selected a cell without data in it in the same group it would only delete that one row. For instance, if all my data is in column A and you selected cell C5 within a group and ran the macro it would only delete row 5, not the entire group. However, if you selected cell A5, where the data is located and ran the macro, it would select the entire group and delete the entire group. Not sure why it's doing this.

If possible, I need to add the row above the group to be highlighted and deleted as well with the macro. It is a total row that sums the group below it. So when someone clicks a cell in that group and clicks on my macro enabled button named "Delete Group", the entire group plus the over line total row deletes with it. Here is a snapshot.
12055 When I run my macro I want the entire the group that cell C8 is in plus the over line total row which is not technically in the group itself to delete.

Your help is greatly appreciated.

p45cal
08-09-2014, 06:39 AM
You're happy to delete entire rows of the sheet, not just the contents of the entire rows, or even just the contents of some of the columns in the rows?