PDA

View Full Version : [SOLVED] Code Not Iterating Each Worksheet



richardSmith
06-13-2014, 04:57 AM
I am trying to use this to iterate each worksheet in a workbook - but the problem is it's not iterating each sheet, it will do the 1st sheet properly and then nothing.


Dim wks As Worksheet
For Each wks In Worksheets
wks.Range("A:A").ColumnWidth = 20.14
Next wks
Set wks = Nothing

ranman256
06-13-2014, 05:21 AM
activate the sheet 1st



For Each wks In Worksheets
wks.select

richardSmith
06-13-2014, 05:38 AM
Nothing it hits my error block. Here is more of my code to see if you can help troubleshoot


On Error GoTo Skip
Set openedWorkbook = Workbooks.Open(directory & fList(inftFno))
'hits this line then hits error block
For Each wks in Worksheet
wks.Range("A:A").ColumnWidth = 20.14
Next wks
'More code here
Skip:
Next
Else: End If

snb
06-13-2014, 05:58 AM
For Each wks In WorksheetS

Remove that error check to start with
Range("A:A") isn't a column; columnwidth is a property of a column, not the property of a range.


For each sh in sheets
sh.columns(1).columnwidth=40
next