Jake
This is BRILLIANT stuff.
Just what I'm looking for.
I know I'm going to start to be a pain now, but can I ask you (or any others
out there) the following:
1) Is there a guide anywhere on this strong type method? As far as I can
fathom, the only bit that seems different is that you have to dim your vars
with 'As ADODB Recordset, etc'. Is this really it?
2) Where does one learn all this Cells, Rows, End up malaki??? Is there any
kind of no b*&*&t syntax listed anywhere?
Putting the extra lines and recordsets is exactly what I want, but I need to
know how to say do the following:
a) Know which row it is to format the columns header of each recordset and
to know how many columns are in each recordset to format.
b) Sum up say a column of recordset data (less the column header) and put
the total either directly underneath it or say at the very bottom of the
report. How can one do this?
c) The ultimate question - can this sort of thing be done on Excel 98/2001
for Mac?? I know the queries can be formatted on this platform, but I bet
there isn't a lovely References item under Tools for the ADo reference -
correct?
Once I can get a firm grasp of the above, I'm set (promise!!).
Thanks
Laphan
Hi Laphan,
Assuming you used vbscript on your ASP documents, then the Excel VBA version
of connecting and getting data into a recordset would be almost identical to
what you did in ASP. The only difference is that you would strongly type
your variables (As ADODB.Recordset, etc). You would need to set a reference
(via Tools | References in the VBE) to Microsoft ActiveX Data Objects
version x.x in order for the project to compile.
To put a recordset on your worksheet, you can use the CopyFromRecordset
method of the Range object:
Sheets("MyData").Range("A1").CopyFromRecordset rsMyRecordset
To find the last row of data, you would do something like this:
Dim lLastRow As Long
With Sheets("MyData")
lLastRow = .Cells(.Cells(.Rows.Count, 1).End(xlUp).Row, 1).Row
End With
So your next recordset would go here:
Sheets("MyData").Cells(lLastRow+2, 1).CopyFromRecordset rsMy2ndRecordset
Keep in mind that Excel worksheets can only handle 65,536 rows, so if your
data sets are large, you may have to put each one on a separate worksheet.
--
Regards,
Jake Marx
MS MVP - Excel
www.longhead.com
[please keep replies in the newsgroup - email address unmonitored]