Results 1 to 2 of 2
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191

    Auto fill Excel Column

    Hi Guy's and happy new year to all

    I have a question, i am using the following code to output DAO Recordset (rs11) to the excel sheet, what i am after doing is having Column I (row 3), (Field7) (not the actual field name, i have added so the correct fields are not listed here) to say YES in I3, if there are for example 14 records in recordset in rs11, the sheet is filled in from rows 3 to 17 up

    I am trying to find the last row used and fill in 14 x YES into each cell in column I row 3 down to I17 (14 records)



    I may well have explained this poorly, forgive if so

    Note all Dims are set lRow is set as Long
    Cells 3,8 are not adding yes in ?

    Code:
    Set apXL = CreateObject("Excel.Application")Set xLWB = apXL.Workbooks.Open(hpOpen & hfOpen)
    apXL.ActiveWorkbook.SaveAs hpSave & hfSave
    apXL.Workbooks.Open hpSave & hfSave, True, False
    apXL.Visible = False
    With xLWB
    .Worksheets(1).Cells(3, 3).CopyFromRecordset rs11
    LRow = .Worksheets(1).Cells(Worksheets(1).Rows.Count, 3).End(xlUp).Row
    .Worksheets(1).Cells(3, 8 + rs11.RecordCount).Value = "YES"
    .Save
    xLWB.Close
    apXL.Quit
    Set apXL = Nothing
    End With
    This is an example of the Excel Template file, i have manually typed YES in the Column

    Click image for larger version. 

Name:	Excel Snip.JPG 
Views:	9 
Size:	69.1 KB 
ID:	40716

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Simplest would probably be to add a field to the query the recordset is based on.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 09-02-2017, 09:11 PM
  2. Auto Fill
    By Derrick T. Davidson in forum Forms
    Replies: 4
    Last Post: 07-12-2014, 08:19 AM
  3. Replies: 2
    Last Post: 01-26-2013, 07:53 PM
  4. Auto-fill
    By sidewayzalex in forum Database Design
    Replies: 49
    Last Post: 09-14-2011, 11:12 AM
  5. Auto fill a due date column in a query
    By Dexter in forum Queries
    Replies: 7
    Last Post: 02-23-2011, 07:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums