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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

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