Macros - select non-contiguous columns

datadrvn

Board Regular
Joined
Apr 7, 2005
Messages
86
How can I select non-adjacent columns (or rows) without multiple commands? For example, the following cleans up a bunch of column widths for me. As you can see, there are multiple columns that are not adjacent to each other that need widths of 10. Is there a way to do this with a single selection? Not a big deal for sure...just trying learn better and more efficient methods.

Columns("A:A").ColumnWidth = 5.89
Columns("C:C").ColumnWidth = 7
Columns("D:G").ColumnWidth = 10
Columns("H:H").ColumnWidth = 5.29
Columns("I:L").ColumnWidth = 10
Columns("O:S").ColumnWidth = 10
Columns("T:T").ColumnWidth = 7

Thanks. Wayne
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Peter & PGC...thank you both very much. Excellent...just what I was looking for. I was already in the middle of making my changes with Peter's reply and I've also given PGCs a try. I actually used both on different actions to help me remember there are multiple ways.

Thank you.

btw...is there an advantage of one over the other in your mind? Not tyring to create one-upsmanship...just wondering if one executes faster or has some other inherent advantages, perhaps in other applications.

Thanks, again.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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