Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel : Select method or Range class failed

Status
Not open for further replies.

actuaryinworks

Technical User
Apr 2, 2006
7
CA
Hi all,
I am using the following syntax in Excel's VBA:

xlWBMe.Sheets(sheetname).range(startletter & startline).Select

where xlWBMe = ActiveWorkbook

The same exact syntax works in another workbook. When I copied it into my current workbook, the 'r' in range became small and Excel gives me the error: Select method or Range class failed

Anybody knows why that happens?

 
Try to debug the line. Dim variables and split line. This should allow to find objects you work with:

dim xlWBMe as Workbook
dim xlWks as Worksheet ' more precise than Sheets(x)
dim xlRng as Range

set xlWBMe=Activeworkbook
msgbox xlWBMe.Name
set xlWks=xlWBMw.worksheets(sheetname)
msgbox xlWks.Name
set xlRng=xlWks.Range(startletter & startline)
msgbox xlRng.Address

combo
 
Are you using a variable named 'range'? Is there a sub/function which shares names? Any missing references?

-----------
Regards,
Zack Barresse
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top