Unable to get the SpecialCells property of this Range Class

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
 
G

George Nicholson

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?
 
G

Guest

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top