D
davidm
Can someone explain why this code generates "Object doesn't support this
property or method" error?
Sub LoopThruWkBooksWkSheets()
Dim wb as WorkBook
Dim ws as WorkSheet
For Each wb In Workbooks
For Each ws In Worksheets
wb.ws.Cells.ColumnWidth = 3 ----> error line
Next
Next
End Sub
The idea is to loop through all open workbooks and all worksheets
therein to reset the columnwidths to 3. The above code can be tweaked
to work by activating each Workbook as in:
Sub LoopThruWkBooksWkSheets()
Dim wb as WorkBook
Dim ws as WorkSheet
For Each wb In Workbooks
wb.activate
For Each ws In Worksheets
ws.Cells.ColumnWidth = 3 ----> error line
Next
Next
End Sub
...but this is arguably not elegant even by turning off
screenupdating.
TIA
David
property or method" error?
Sub LoopThruWkBooksWkSheets()
Dim wb as WorkBook
Dim ws as WorkSheet
For Each wb In Workbooks
For Each ws In Worksheets
wb.ws.Cells.ColumnWidth = 3 ----> error line
Next
Next
End Sub
The idea is to loop through all open workbooks and all worksheets
therein to reset the columnwidths to 3. The above code can be tweaked
to work by activating each Workbook as in:
Sub LoopThruWkBooksWkSheets()
Dim wb as WorkBook
Dim ws as WorkSheet
For Each wb In Workbooks
wb.activate
For Each ws In Worksheets
ws.Cells.ColumnWidth = 3 ----> error line
Next
Next
End Sub
...but this is arguably not elegant even by turning off
screenupdating.
TIA
David