Fixed Column Width/Autofit Row

SDave

Board Regular
Joined
Aug 12, 2008
Messages
152
Office Version
  1. 365
Platform
  1. MacOS
Does anyone know of or have a VBA code that enables you to fix column width yet autofit rows?!

I would like columns E:G to have their width fixed to 75, yet still allow rows E12:G16 to autofit.

I was previously using the following so that columns E:G autofitted, as and when data was pulled into their corresponding cells, however I have been asked to slightly tweak things:

Private Sub Worksheet_Calculate()
Columns("E:G").EntireColumn.AutoFit
End Sub

Any help would be much appreciated.

Thanks!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Try

Code:
Private Sub Worksheet_Calculate()
With Columns("E:G")
    .AutoFit
    .WrapText = True
End With
End Sub
 
Upvote 0
Are you talking about column widht being fixed and row height being autofit.
Code:
Range("E:G").ColumnWidth = 75
Range("12:16").Rows.Autofit

Or are you talking about Columns E:G having one width except for rows 12:16, which have different widths. No, because if any cell in a column is wider than the others, then its not a column.
 
Upvote 0
Mike,

Yes - column width being fixed and row height being autofit.

I've used the code that you've supplied, which by the way works great - much appreciated. Is there anyway I could also specify that the autofit range should also wrap text?!

VOG, thank you for your help - again it's much appreciated, the code you supplied worked much in the same manner as my original code?!
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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