PDA

View Full Version : Selecting/deselecting rows - then sort & Hide/Unhide rows



Rasm
05-05-2011, 05:56 AM
The purpose of this code is to easily sort data – then hide/unhide rows – next I assign a product code (using treeview keys – so I can have as many relationships as I want – emulating a relational database – Next I can query product codes – that way I can find say all 6 cylinder cars of the brand Ford or the brand Chevy or both and so on – all depends on my treeview key – Anyway this code don’t show the treeview).

The code allow you to select entire rows on the sheet directly using Shift+Mouse_Click or Ctrl+Mouse_click – there is a hidden userform that that will track your selection if the range exceeds 254 characters – dam 255 number in Excel. So simply select rows using the mouse – on the visible userform use the ‘Add’ to assign a True value or ‘Remove’ to assign a False value for the highlighted rows in the column ‘Selected’. You may also toggle the True/False value by a simple click on a cell in the Selected Column – again these changes are trapped by the hidden form. This also allow you to load other forms and simply get the selections from the hidden form. This feature has only real value if you have > 10K rows or something like that in your sheet.
After you made your selection you can checkmark the selected records-any records with the value false can now be hidden – ‘Hide by checking box’ and UnHidden by unchecking box.
You can click on the header column to sort by that value – just like an explorer bar option – unfortunately to toggle between ascending/descending – you have to click cell above or below the header – then click the header again – I cannot figure out how to trigger event without pulsing the value. The purpose of the Position column is simply to allow the data to be sorted in order of entry.
If anybody has suggestions or similar routines I would be very appreciative. I have been using VB6 for years – but is new to all the XL functions. So just finding my way around in coding in XL.

Admin
05-05-2011, 08:31 PM
Hi Rasm,

You'll find in this post (http://www.excelfox.com/forum/showthread.php?54-Find-All-Cells-That-Contain-A-Certain-Value&p=123&viewfull=1#post123) how I tackle the 255 character limit.

Rasm
05-06-2011, 02:59 AM
Yes - I properly should take another look - thanks for reminding me - however what I use right now is actually quite quick. But I definitely will. The portion of the code here is what I use on a number of different userforms - so I will optimize it further in this development code. Before I implement across the board.