Unable to get the SpecialCells property of this Range Class

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Here is the code that generates the error. The error message occurs at the
line using specialcells.

NewFN = "C:\worksheet 3-29.xls"
Set xlapp = CreateObject("Excel.Application")
xlapp.Workbooks.Open Filename:=NewFN
xlapp.ActiveWorkbook.Sheets(1).Select
Set Wb = xlapp.ActiveWorkbook
xlapp.Worksheets("Sheet1").Range("$a$1").Activate
xlapp.ActiveSheet.Unprotect
xlapp.ActiveCell.SpecialCells(xlLastCell).Select
MsgBox xlapp.ActiveCell.Row
xlapp.ActiveSheet.Unprotect

Thanks for your help
 
try the correct argument: xlCellTypeLastCell

and, since ActiveCell refers to a single cell, isn't
xlapp.ActiveCell.SpecialCells(xlCellTypeLastCell).Select
the same as
ActiveCell.Select? (i.e., the last cell of a single cell range will be
that cell)

and since it's the ActiveCell, do you need to select it?
 
Thanks George, very much appreciated.

George Nicholson said:
try the correct argument: xlCellTypeLastCell

and, since ActiveCell refers to a single cell, isn't
xlapp.ActiveCell.SpecialCells(xlCellTypeLastCell).Select
the same as
ActiveCell.Select? (i.e., the last cell of a single cell range will be
that cell)

and since it's the ActiveCell, do you need to select it?
 
Back
Top