Fixing column widths without moving rest of sheet?

inkbird1

Board Regular
Joined
Apr 21, 2020
Messages
51
Hi, quick question

Is there a way to fix column widths in a section of the worksheet so that when working around this area the column widths dont move in the fixed area?

Capture.PNG
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
If you mean that you don't want A:X to ever change widths, you can do that with VBA. You'd have to note the current widths, and upon worksheet change, reset the widths to those. For example, if you want the widths to always be 8.1, you can do this -- right-click the sheet tab, select View Code, enter this:
Private Sub Worksheet_Change(ByVal Target As Range)
Range("A:X").ColumnWidth = 8.1
End Sub

If the widths are varying, let me know and I'll give the more involved answer.
 
Upvote 0
If you mean that you don't want A:X to ever change widths, you can do that with VBA. You'd have to note the current widths, and upon worksheet change, reset the widths to those. For example, if you want the widths to always be 8.1, you can do this -- right-click the sheet tab, select View Code, enter this:
Private Sub Worksheet_Change(ByVal Target As Range)
Range("A:X").ColumnWidth = 8.1
End Sub

If the widths are varying, let me know and I'll give the more involved answer.

Thanks, the image attached is apart of a worksheet, the widths of the surrounding cells are varying, I just need to the cells under the times to stay the same
 
Upvote 0
Let's say the widths from A:E are 8,12,6,6,6 you'll get the idea from these 5 columns)
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
For i = 1 To 5
Columns(i).ColumnWidth = Array(8, 12, 6, 6, 6)(i - 1)
Next
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,240
Members
448,555
Latest member
RobertJones1986

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