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/425220-invalid-unqualified-reference-error.html)

Stanley Braverman

Invalid or unqualified reference error
 
Getting Invalid or unqualified reference error at .Cells

Sub wordwrap()

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

End Sub



Leith Ross[_769_]

Invalid or unqualified reference error
 

Stanley Braverman;260814 Wrote:
Getting Invalid or unqualified reference error at .Cells

Sub wordwrap()

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

End Sub


Hello Stanely,

You can write this a couple of ways:
---------------------------------------------------------------
Sheets("Sheet1").rows("1:" & Sheets("Sheet1").Cells(Rows.Count,
"A").End(xlUp).Row).AutoFit

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


--
Leith Ross

Sincerely,
Leith Ross

'The Code Cage' (http://www.thecodecage.com/)
------------------------------------------------------------------------
Leith Ross's Profile: http://www.thecodecage.com/forumz/member.php?userid=75
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=72780



All times are GMT +1. The time now is 05:01 AM.

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