View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
deko[_3_] deko[_3_] is offline
external usenet poster
 
Posts: 62
Default How to reference worksheet name with spaces?

I've read that single quotes are supposed to allow you to reference
worksheet names with spaces:

'Year 2004_0'

But I'm using automation (from Access) and it's not working:

sn = 'Year 2004_0'

lr = xlapp.Workbooks(strXlsFile).Worksheets(sn) _
.Range("A1").SpecialCells(xlCellTypeLastCell).Row

This returns "Error Number 9: Subscript out of range"
(works fine if no spaces in worksheet name)

I've also tried:

['Year 2004_0']

but no luck.

How can I reference a worksheet name with spaces when using automation?

Thanks in advance.