Experts,
I tried many codes from the internet to invert Cells selection at excel, but they doesnt work.
Anyone has a code that can be shared with me? I just want to select a cell or cells, execute the macro and invert selection of them.
thanks!
Experts,
I tried many codes from the internet to invert Cells selection at excel, but they doesnt work.
Anyone has a code that can be shared with me? I just want to select a cell or cells, execute the macro and invert selection of them.
thanks!
Select a range (up and down) and try this.
Long winded but it should do until someone comes with a shorter code (Not faster I think!!!!)![]()
Please Login or Register to view this content.
Assuming you have a specific range of cells you want to invert (and not the entire worksheet), this should work. This code only scans the range C4:H15, so expand your range as needed. It checks to see if each cell in that range is selected, and if not, creates a list of those cells, then finally selects those addresses.
![]()
Please Login or Register to view this content.
A second possibility.
Again, if I understand your request right.
Select a vertical range and run this.
![]()
Please Login or Register to view this content.
And my last suggestion.
![]()
Please Login or Register to view this content.
Thanks all for respond Thread but they didnt work
Thew swap the values between selection, but doesn't select the oposite cells.
I mean, if i Select A1:A5 and B3:B7. When i run the macro, i want to select rest of the workbook cells. this means, All from A6 to AXXXX and B1:B2 and B8 to XX:XX
What is the purpose of this? What are you trying to achieve?
Selecting is very seldom needed so there should be an alternative
Last edited by jolivanes; 08-30-2021 at 06:51 PM.
Good question. I requiere it for two different scopes:
1. First. Select All Locked Cells , excluding Un-Locked ones. This means, the oposite of this code:
2. Second. Swap cells selection, this means, if i have A,B,C cells selected. When i execute the macro this three will be un-select and the rest of the cells sheets should be selected.![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
What if you change the "False" to "True" here?
and change all the "unlockedCells" to "lockedCells".![]()
Please Login or Register to view this content.
Also make sure when you protect your sheet that you can select both locked and unlocked cells.
I ran this on a temporary test book and it works as you want (I think).
For locked cells, copy this same macro but change "True" to "False" and in the message change "Unlocked" to "Locked".![]()
Please Login or Register to view this content.
But there still is the question of why select cells. What are yoy going to do with the selected cells?
Last edited by jolivanes; 08-31-2021 at 05:56 PM.
Thanks for the code, it works for other porpoise. But not for what i need, let me answer your question, that probably can clarify what i want to do.
But there still is the question of why select cells. What are yoy going to do with the selected cells?
I need to invert selection from Locked to Unlocked cells and Viceversa when the workbook its not Protected (Locked). This because i programmed a sub routine to right click in order to identify witch cells are locked and witch cells are not. That's why i need to Select a range, then when macro executes. Locked or Unlocked cells needs to be selected, depending on the option clicked.
This will execute different sub routines based on if they're locked - selected or unlocked selected.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks