CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 1998
    Posts
    1

    Excel automation



    Hi!


    How can I fill a range of cells on Excel worksheet without moving

    from cell to cell and inserting the data into each cell?

    Besides I can't use Clipboard to perform such an operation


    Thanks for any reply.

    Alex.



  2. #2
    Join Date
    May 2001
    Location
    UK
    Posts
    11

    Re: Excel automation

    Two methods to try:
    The CopyFromRecordset method allows you to copy an entire recordset (DAO only for Excel 97, or, both DAO and ADO for Excel 2000 as I've just discovered with Kostas) into any Range object, thus:

    MyRange.CopyFromRecordset myrecordset

    Or, if you're not using recordsets, you can fill a 2-dimensional string array with your values, then, just tell Excel to make the appropriate range equal to your array, thus:

    MyRange = MyArray()

    I know that's very general, but if you need anything more specific or can say what software versions etc you're using, let us know. There's also more info' on referring to Range objects etc in the appropriate Help files if you need it.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured