ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Invalid or unqualified reference error (https://www.excelbanter.com/excel-programming/425221-re-invalid-unqualified-reference-error.html)

Stanley Braverman

Invalid or unqualified reference error
 
Getting Invalid or unqualified reference error

Sub wordwrap()

Sheets("Sheet1").rows("1:" & .Cells(.rows.Count, "A").End(xlUp).Row).AutoFit

End Sub



Tim Williams[_2_]

Invalid or unqualified reference error
 
Maybe you meant:

With Sheets("Sheet1")
.rows("1:" & .Cells(.rows.Count, "A").End(xlUp).Row).AutoFit
End With

If you use a bare "." like in your ".Cells" it needs to be in the context of
a "With...End With" block.
I would also suggest qualifying the workbook for the worksheet.


Tim

"Stanley Braverman" wrote in message
...
Getting Invalid or unqualified reference error

Sub wordwrap()

Sheets("Sheet1").rows("1:" & .Cells(.rows.Count,
"A").End(xlUp).Row).AutoFit

End Sub






All times are GMT +1. The time now is 03:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com