VBA Amend Column Width (Problem is Merged Cells)

velohead

Board Regular
Joined
Aug 22, 2007
Messages
205
Hi All,

I need to automatically amend a column width, which is easy with VB.
Script supplied below.

However, the author of the spreadsheet decided in their wisdom (d'oh!) to incorporate merged cells.
Unfortunately, I need to retain these numerous and illogically placed merged cells.

is there a way to amend the column width with VB please.
It works when you do it manually !!!!

When VB is used, the result is to amend the column width of all columns that have a merged cell that includes that column.

Code:
Sub Macro7()
x = InputBox("enter column width")
Columns("M:M").Select
Selection.ColumnWidth = x
End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Does this make any difference?
Code:
Sub Macro7()
    x = InputBox("enter column width")
    Columns("M:M").ColumnWidth = x
End Sub
 
Upvote 0
Yes, it works perfectly. Thank You Norie.
(I think you have helped me in the past, too) :)
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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