VBA Amend Column Width (Problem is Merged Cells)

velohead

Board Regular
Joined
Aug 22, 2007
Messages
212
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

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).
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,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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