add pixels after autofit

still learning

Well-known Member
Joined
Jan 15, 2010
Messages
784
Office Version
  1. 365
Platform
  1. Windows
Hi
Can I add to this macro to add 10 pixels after it autofits the column?
I have this on the Quick Access Toolbar for all workbooks
VBA Code:
Sub autosize()
    Selection.Columns.AutoFit
End Sub
I want to be able to increase the width 10 pixels after the macro runs

mike
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi
What about
VBA Code:
Sub autosize()
    Selection.Columns.AutoFit
    Selection.ColumnWidth = 10 + Selection.Columns.Width
End Sub
 
Upvote 0
Hi Zot
I looked at the link and after changing the the width size, I was able to get what wanted
Thank You

Hi mohadin
It change the width to much. I use different numbers and couldn't get to work. I gave up at
.000000000000000000001 + Selection.Columns.Width
that increased to to about 7.5 times the width
Thanks for trying

mike
 
Upvote 0
Hi Zot
I looked at the link and after changing the the width size, I was able to get what wanted
Thank You

Hi mohadin
It change the width to much. I use different numbers and couldn't get to work. I gave up at
.000000000000000000001 + Selection.Columns.Width
that increased to to about 7.5 times the width
Thanks for trying

mike
Glad the link helped
 
Upvote 0

Forum statistics

Threads
1,214,657
Messages
6,120,764
Members
448,991
Latest member
Hanakoro

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