Change column width

Hatye

Board Regular
Joined
Jan 11, 2010
Messages
143
Hi,
I want to change column width on the following columns in my worksheet: O, S, W, AA, AE, AI from 2 to 1.
What I have is this:

Code:
    Range("O:O,S:S,W:W,AA:AA,AE:AE,AI:AI").Select
    Selection.ColumnWidth = 1

The problem is that it is selecting all columns from B to AI. I have some merged cells whitin the range, so I guess that that has something to do about it, but I can't figure out what to do. Can anyone help me with this? :)
However, it does work when I do it manually (when recording the macro).
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Do you have a row that doesn't have any merged cells? Maybe you should be using the horizontal alignment 'Center across selection' instead of merged cells.
 
Upvote 0
Hi Andrew Poulsom and than you for the reply,

No, I don't have any whole columns that don't contain merged cells. It is unfortunately a lot of work to not use merged cells. This is a report template, which is specially adapted to different purposes. All columns width are 2, and it uses merged cells actively to get the correct layout for the report.
Now there is a report which needs to be adjusted, so that the columns mentioned in the first post must have the width 1.

Since it works when I do it manually, shouldn't it work with when I run it as a macro?
 
Upvote 0
I asked about rows not columns. Surely you haven't merged the cells in every row of the columns whose width you want to change?
 
Upvote 0
Oh, I'm sorry, I misread; my fault!

Yes, I have several rows that doesn't conatain any merged cells. E.g. row 1, 6, 9, 40.
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,391
Members
448,957
Latest member
Hat4Life

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