View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
bigwheel bigwheel is offline
external usenet poster
 
Posts: 222
Default Macro for column width

You could leave out all the lines that start with Range but otherwise, it
works for me. Try stepping through the macro (F8) and observe what happens
on your spreadsheet.

"Martincito23" wrote:

Hi,

I'm trying to make a macro which allows me to format a sheet. One of the
formats that I want to add in the macro is the column width. Below there is
part of the macro that I'm using in order to adjust the column width:

Columns("A:A").Select
Range("A3").Activate
Selection.ColumnWidth = 8
Columns("B:B").Select
Range("B3").Activate
Selection.ColumnWidth = 15
Columns("C:C").Select
Range("C2").Activate
Selection.ColumnWidth = 20
Columns("D:D").Select
Range("D2").Activate
Selection.ColumnWidth = 9
Columns("E:E").Select
Range("E3").Activate
Selection.ColumnWidth = 9
Columns("F:F").Select
Range("F3").Activate
Selection.ColumnWidth = 11
Columns("G:G").Select
Range("G2").Activate
Selection.ColumnWidth = 7
Columns("H:H").Select
Range("H4").Activate
Selection.ColumnWidth = 12
Columns("I:Q").Select
Selection.ColumnWidth = 5


The problem that I'm having is that from Columns A:H, the column width stays
at 12, and I:Q stays at 5. I'm actually expecting to have the columns A:H
with the width detailed in the macro. I know that there is something wrong in
the macro, but I can find what it is.

Can you please help me out??
Thank you!!