Change ColumnWidth for Multiple Columns?

A

AJ Master

I need to be able to change the column width on multiple columns (all
next to each other) on one sheet (i.e. codename: sheet10) based on
user data selected from a combobox on sheet1.

I have tried using this but it always fails, so I would really
appreciate any help on fixing it:

with sheet10 'codename for sheet
.unprotect
.columns(4,zColCount).columnwidth=dblColWidth ' col D thru # of
columns entered
.protect
end with

Thanks again....AJ
 
G

Gary Keramidas

how about this? (i added values manually because i don't have your code)

Sub test()
zcolcount = 8
dblColWidth = 12
With Sheet10 'codename for sheet
.Unprotect
.Columns(4).Resize(1, zcolcount).ColumnWidth = dblColWidth '
.Protect
End With

End Sub
 
V

Vergel Adriano

One way is to do it like this:

with sheet10 'codename for sheet
.unprotect
.Range(Cells(1, 4), Cells(1, 4 + zcolcount)).ColumnWidth = dblColWidth
.protect
end with
 
A

AJ Master

how about this? (i added values manually because i don't have your code)

Sub test()
zcolcount = 8
dblColWidth = 12
With Sheet10 'codename for sheet
.Unprotect
.Columns(4).Resize(1, zcolcount).ColumnWidth = dblColWidth '
.Protect
End With

End Sub

Gary,

Yes, thanks that worked perfectly.

AJ
 
A

AJ Master

One way is to do it like this:

with sheet10 'codename for sheet
.unprotect
.Range(Cells(1, 4), Cells(1, 4 + zcolcount)).ColumnWidth = dblColWidth
.protect
end with

Vergel,

Thanks, your code worked as well. I appreciate everyones help with
this.

AJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top