
Output to excel - "Subscript out of range" error
Quote:
>Dim xl As New Excel.Application
>Dim xlSheet As Worksheet
> Set xlwbook =
>Workbooks("ScorecardOutput.xls").Sheets("Scorecard")
> Set xlSheet = xlWbook.Sheets("Scorecard")
> with xlSheet
>etc but no joy. any ideas where i'm going wrong?
If that's your actual code, xlwbook needs to be a member of the
application object (xl), and you haven't declared it at all, so
you're trying to 'Set' an Object that doesn't exist;
Dim xl As Excel.Application
Dim xlwbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Set xl = New Excel.Application
' NOTE: xlwbook = *XL*.Workbooks.Open...
Set xlwbook = xl.Workbooks.Open("c:\ScorecardOutput.xls")
Set xlsheet = xlwbook.Sheets("Scorecard")
With xlsheet
.Range()...etc...
HTH
--
Alfie [UK]
<http://www.delphia.co.uk/>
If you meet someone without a smile.......give them yours.