1/. The Toggle Columns button should hide/unhide column Q together with columns U:CQ.
Changes
I have added "Q" to the if statement to define the exact condition to toggle under.
I have changed the Toggle Button caption to suit.
2/. For column D, there should be three cases
Changes
None - Your code modification is fine.
3/. Columns S:T should be hidden when CM, LR, MG or NR is selected, and unhidden when any other code is selected.
Changes
I have added Columns("S:T").Hidden = False to Case "CR", "GN", "PA", "SC" to fullfill the unhidden condition.
4/. If the user deletes the contents of a cell in column D, the contents of the cells in columns Q and S:CQ for that row should be deleted, and all columns unhidden.
Changes
I have added code to handle this condition. It will require testing to cover possible user situations I am unaware of
Note the use of Application.EnableEvents = False/True in this additional code.
5/. Instead of: ‘if delete is used (in column Q) then unhide all columns and exit,.........
Changes
I have added code to handle this condition.
Code in 4/. will override this on occassions , this is unavoidable, but it is probably correct to do so.
In most of the above, I cannot say for sure that the result is correct, I cannot verify the required conditions, only you can do this.
The methods used, however, should put you on the right track.
6/. Also, can you please explain “isect”? It’s the first time I am seeing it in macros.
This is the variable name Set by the Intersect function.
In this line
Set isect = Application.Intersect(Target, Range("D:D,Q:Q"))
Highlight Intersect press f1 to see an explaination by microsoft
In my experience Worksheet_Change is seldom used without it.
Help in Excel VBa is invaluable it contains a mine of information. Use it!!!
I have attached an amended workbook for your evaluation.
Please let me know how you get on with it.
Regards
Alistair
If this takes care of your needs, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody!
Also
If you are satisfied by any members response to your problem please consider using the scales icon top right of thier post to show your appreciation.
Bookmarks