ColumnWidth not working...

  • Thread starter Thread starter BEE
  • Start date Start date
B

BEE

Here's my code:
rc = 15
ColPlace = 1
For counter = 0 To rc - 1
wb.Worksheets("Sheet1").Columns(ColPlace).ColumnWidth = 10
ColPlace = ColPlace + 1
Next

I did this cause I couldn't get a range option to work in
this scenario either. How? What am I missing?

Thanks in advance,
B.
 
FIXED:
rc = 15
ColPlace = 1
For counter = 0 To rc - 1
wb.Sheets(1).Columns(ColPlace).ColumnWidth = 10
ColPlace = ColPlace + 1
Next

Thanks tho,
B
 
Sub Tester1()
Set wb = ActiveWorkbook
rc = 15
ColPlace = 1
For counter = 0 To rc - 1
wb.Worksheets("Sheet1").Columns(ColPlace).ColumnWidth = 10
ColPlace = ColPlace + 1
Next

End Sub


Worked fine for me.

wb.Worksheets("Sheet1").Cells(1,ColPlace).Entirecolumn.ColumnWidth = 10

would also work.
 
You don't have a sheet named Sheet1. So why try to set the columnwidth on a
sheet named Sheet1?

Regards,
Tom Ogilvy
 
Back
Top