I need to export data to an Excel sheet in order to produce a chart for that data.
The problem I have at present is that I do not know how to refer to variable rows
in SetSourceData. (See line 28 where *** can be any no depending on the no of records Returned by the query in line 11). Is there a way to use variables in row/col ranges instead of fixed col/rows? (i.e. "A2:B99"
.
Any help on this will greatly appreciated.
Thank you for you time & help.
NW
1. objExcel = CreateObject("Excel.Application"
2. ObjBook= ObjExcel.WorkBooks.Open("c:\reports\graph.xls"
3. objexcel.visible = .t.
4.
4. With objSheet
5. .Range("A1"
.Value = "Namer"
6. .Range("B1"
.Value = "Count"
7. EndWith
8.
9. **** SQL STATMENT FOR DATA....
10.
11. SELECT NAME, COUNT(NAME) AS COUNT1 INTO CURSOR cCursor
12. SELET cCursor
13.
14. nRow = 2
15.
16. SCAN
17. With objSheet
18. .Cells(nRow, 1).Value = cCursor.name
19. .Cells(nRow, 2).Value = cCursor.Count1
20. EndWith
21. nRow = nRow + 1
22. ENDSCAN
23.
24. With objExcel
25. .Charts.Add
26. With .ActiveChart
27. .ChartType = xlColumnClustered
28. .SetSourceData(objExcel.Sheets("Sheet1"
.Range("A2:B***"
, xlColumns)
29. EndWith
30. ENDWITH
[sig][/sig]
The problem I have at present is that I do not know how to refer to variable rows
in SetSourceData. (See line 28 where *** can be any no depending on the no of records Returned by the query in line 11). Is there a way to use variables in row/col ranges instead of fixed col/rows? (i.e. "A2:B99"
Any help on this will greatly appreciated.
Thank you for you time & help.
NW
1. objExcel = CreateObject("Excel.Application"
2. ObjBook= ObjExcel.WorkBooks.Open("c:\reports\graph.xls"
3. objexcel.visible = .t.
4.
4. With objSheet
5. .Range("A1"
6. .Range("B1"
7. EndWith
8.
9. **** SQL STATMENT FOR DATA....
10.
11. SELECT NAME, COUNT(NAME) AS COUNT1 INTO CURSOR cCursor
12. SELET cCursor
13.
14. nRow = 2
15.
16. SCAN
17. With objSheet
18. .Cells(nRow, 1).Value = cCursor.name
19. .Cells(nRow, 2).Value = cCursor.Count1
20. EndWith
21. nRow = nRow + 1
22. ENDSCAN
23.
24. With objExcel
25. .Charts.Add
26. With .ActiveChart
27. .ChartType = xlColumnClustered
28. .SetSourceData(objExcel.Sheets("Sheet1"
29. EndWith
30. ENDWITH
[sig][/sig]