Select every 5th column

GreenyMcDuff

Active Member
Joined
Sep 20, 2010
Messages
313
Hi guys,

I have a spreadsheet (Excel 2003) and need to alter the column widths.

I need it so that from column 4 onwards, every 5th column is selected and made 158pixels wide

Also I need all the columns in between selected and made 34 pixels wide.

I thought it might be possible to do it using Arithmetic Pregrssions???

So,
Columns: 4,9,14,19,...,5n-1 need to be selected and made 158 pixels wide

Columns: 5,6,7,8,10,11,12,13,15,16,...,5n+3 need to be selected and made 34 pixels wide

I hope this makes sense :)

Cheers

Chris
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Try:
Code:
Sub test()
For i = 4 To 100 'substitute 100 with your number
    Rows(i).RowHeight = 34
Next
For j = 4 To 100 Step 5 'substitute 100 with your number
Rows(j).RowHeight = 158
Next
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

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