Excel VBA Range object Error in Looping Through Worksheet
问题 I am trying to loop through different sheets in my workbook. I have tried searching through stackoverflow but still stuck with the error. The error showed "Method 'Range' of object'_Worksheet' failed. The purpose of this code is to standardise all formats in the worksheets. Sub formatting() Dim ws as Worksheet Dim lastRow as long, lastColumn as long lastRow = Range("A" & Rows.Count).End(xlUp).Row lastColumn = (Cells(1, Columns.Count).End(xlToLeft).Column) For each ws in Activeworkbook