0

'for lastrow giving me message Methold range of object worksheet failed

With Rep
.Unprotect ("000")
LastRow = .Range("F6:F" & LastRow).End(xlUp).Row + 1
.Range("$C$6:$Z$6").AutoFilter
.Protect Password:=("0000")

Me.CbInvStore.Value = .Cells(LastRow - fw2, "C") 'inv_store
Me.Lbl_typ.Caption = .Cells(LastRow - fw2, "E").Value 
Me.TbInvNo.Value = Format(.Cells(LastRow - fw2, "F").Value, "00000")
BigBen
  • 46,229
  • 7
  • 24
  • 40
  • 2
    You can't use `LastRow` like this before you've assigned it a value. `.Range("F6:F" & LastRow)`: here `LastRow` equals `0`, and there is no row zero. – BigBen May 01 '23 at 15:07
  • So what I can do as I want to make the code to find the lastrow instead I do RANGE ("F8000") – Mohamed Amin May 01 '23 at 15:12
  • Filtered but without any data showing up the userform is empty – Mohamed Amin May 01 '23 at 15:18
  • LastRow =.Range("F80000").End(xlUp).Row + 1 'for this code its work but I don't want make the data in limited – Mohamed Amin May 01 '23 at 15:20
  • ALso with this code LastRow = .Range("F80000").End(xlUp).Row + 1 i have to resize the table to 80000 to get the data – Mohamed Amin May 01 '23 at 15:20
  • 2
    If you have data formatted as a table (`ListObject`), then see [this thread](https://stackoverflow.com/questions/43631926/lastrow-and-excel-table). – BigBen May 01 '23 at 15:22

0 Answers0