Increase/Decrease Column Size with Icon

RMXByker

New Member
Joined
Apr 1, 2010
Messages
38
I'm am looking for something that I thought would be relatively easy. This is proving to not be the case for the amount of knowledge in VBA I have obtained. I would like a Plus and Minus icon on a spreadsheet and use these to increase/decrease a specific columns width. The key is I want to increase either by 20% or something like a specific value (5). These both rely on using the current width with a multiplier or additive. Any ideas? Below is what I was tinkering with but no luck so far.

Code:
Sub ColumnIncrease()

ActiveSheet.Unprotect Password:="UNPROTECTME"
       
Dim cw As Long
Set cw = .Columns("Z").ColumnWidth
        
With Worksheets("Test Plan").Columns("Z").ColumnWidth = cw + 5
End With
    
ActiveSheet.Protect Password:="PROTECTME", AllowInsertingRows:=True, AllowDeletingRows:=True, AllowFormattingCells:=True


End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
My script only increases the value. I edited out my code but you must have seen it before my edit. And then my percentage plan may not work. If you want one for decresing amount just modify this script and make two scripts. My math is not the best so maybe you can modify script to add or decrease by certain percentage amounts
Flawless. Thanks a ton MyAswerIs. I will also add in some error proofing for if the user hits the "X" button as well. Thanks a lot!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top