View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jan Karel Pieterse Jan Karel Pieterse is offline
external usenet poster
 
Posts: 535
Default How to reference worksheet name with spaces?

Hi Deko,

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


Make that:

sn = "Year 2004_0"

When using the Worksheets collection from VBA, the single quotes are
not needed.

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com