[AccessD] Manipulating Excel Cells

Hale, Jim Jim.Hale at FleetPride.com
Wed Feb 1 11:03:00 CST 2006


When you think about it a cell location in Excel can be definitively
described by knowing the workbook, worksheet, column and row in which it
resides. When I need to place values in spreadsheet templates (other than
bulk copy recordset pastes). I use a table that stores the 4 elements. I
then use the value of the row and column that I have stored with the cell
method to place the data in Excel. This works for templates that do not
change. If the templates change maintenance with this method becomes
prohibitive. In those cases the more sophisticated method is to store data
(such as an acct number and column offset) in columns A & B of the
spreadsheet. I then read col A & B of the spreadsheet and create a temp
table with the acct number from column A, the column number from column B
and the row number (which I can determine). This table is then joined with
the data by account number creating a recordset with the data to be pasted
and the row and column number in which to paste it. I then iterate through
the recordset something like this:

'Load Data into Excel
    If Not (rstData.BOF And rstData.EOF) Then
          Do While Not rstData.EOF
            intBmonth = rstData(strMo) + rstData(strColOffset)
            intRow = rstData(strRowNo)
            wksUpl.Cells(intRow, intBmonth) = rstData(strAmt)
            rstData.MoveNext
          Loop

HTH 
Jim Hale


***********************************************************************
The information transmitted is intended solely for the individual or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review, retransmission, dissemination or
other use of or taking action in reliance upon this information by
persons or entities other than the intended recipient is prohibited.
If you have received this email in error please contact the sender and
delete the material from any computer. As a recipient of this email,
you are responsible for screening its contents and the contents of any
attachments for the presence of viruses. No liability is accepted for
any damages caused by any virus transmitted by this email.


More information about the AccessD mailing list