Dear Forum.
I'm looking for a macro that would select a group of columns and hide them. I want the selection to be:
the fourth column from the 1st column, up to the 3rd last column. And then hide them.
Any help would be great.
Thank you.
Dear Forum.
I'm looking for a macro that would select a group of columns and hide them. I want the selection to be:
the fourth column from the 1st column, up to the 3rd last column. And then hide them.
Any help would be great.
Thank you.
Last edited by Cidona; 07-03-2011 at 12:58 PM. Reason: Marked as Solved
Try this, assuming you have headers in Row 1
Please Login or Register to view this content.
You also might want to try this
Then use the resulting Grouping Button (-/+) to toggle the columns.Please Login or Register to view this content.
Hope this helps
If you need any more information, please feel free to ask.
However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....
Also
اس کی مدد کرتا ہے اگر
شکریہ کہنے کے لئے سٹار کلک کریں
If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.
Hi Cidona,
Find the attached with the Code you want.
Please Login or Register to view this content.
One test is worth a thousand opinions.
Click the * Add Reputation below to say thanks.
@ MarvinP
Based on this
I think that there could empty columns at the begining of the sheet otherwise Cidona would just have said...I want the selection to be:
the fourth column from the 1st column, up to the 3rd last column.
"I want the selection to be:
From the fourth column up to the 3rd last column"
I might well be wrong, but the code I posted handles either scenario.
Hi Marcol,
After reading our code and seeing I started in Row 1 to find LastColumn, I wondered if we should have used UsedRange or some other method to find the working range s/he wanted.
It is a mystery what the OP is really asking for in many of these questions. That is why I like to supply a workbook to show my assumptions (Row 1 is the column heads) to go along with the code. We'll see if they respond with a "you guys didn't get what I was saying" or if our answers are good enough for them.
Maybe this would be a more general solution?
Please Login or Register to view this content.
Call the macro in "ToggleColumns" like this
if the header row is row 1
ShowHideColumns "from the 4th column" = 4 , "to the third last column" = 3
or if the header row is not row 1Please Login or Register to view this content.
ShowHideColumns "from the 4th column" = 4 , "to the third last column" = 3, "the row number"
e.g.
Please Login or Register to view this content.
A similar approach could be used for the grouping button
We'll see.
Thank you both so much for your replies and in depth anaylsis. And sorry I wasn't more specific. I was trying to keep it simple.
I have ended up using MarvinP's solution. I'm sure all of the proposed methods could be tweeked to work for my situation but I just found Marvin's the simplest to edit. The only item I needed to change here was to change the 1 to a 7 in the line "LastC = Cells(1, Columns.Count).End(xlToLeft).Column 'Last Col in Row 1". This is because I am using the top rows of the worksheet as a location to put various buttons for activating macros. Since I am literally fumbling my way through the learning of macros I found this the easiest way.
BTW Marcol, as far as "I think that there could empty columns at the begining of the sheet otherwise Cidona would just have said...
"I want the selection to be:
From the fourth column up to the 3rd last column"
I might well be wrong, but the code I posted handles either scenario.
I think that was what I was trying to say Sorry for the confusion.
Thank you both again.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks