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

    Access To Excel Entire Column

    Hi Guy's, i am so close with this if anyone can help, the following outputs an update in Excel and testing the BOLD line converts the cells (3, 9) to dd-mm-yy perfect, can i do the entire column from 3 ,9 by rs.recordCount (therefore row 3 to 690) if rs.recordCount is 690 ?

    mStart = Format(Date - Weekday(Date) + 1, "mm/dd/yyyy")
    mEnd = Format(Date + 7 - Weekday(Date), "mm/dd/yyyy")


    Set ApXL = CreateObject("Excel.Application")
    Set XLWb = ApXL.Workbooks.Add
    intSheets = XLWb.Worksheets.Count
    Set xlSheetLast = XLWb.Worksheets(intSheets)
    Set xlSheet = XLWb.Worksheets.Add(, xlSheetLast, 1, xlWorksheet)
    ApXL.ActiveWorkbook.SaveAs (strPathName)
    Set XLWb = ApXL.Workbooks.Open(strPathName)
    ApXL.Visible = True
    Set XlWs1 = XLWb.Worksheets("Sheet1")
    XlWs1.Name = "Deliveries"

    Set rs = CurrentDb.OpenRecordset("SELECT tblAssign.SONumber, tblAssign.DelTo, tblAssign.PONumber, tblAssign.LiftType, tblAssign.LiftNo, tblAssign.Status, tblAssign.DeliveryDate FROM tblAssign WHERE DeliveryDate Between #" & mStart & "# AND #" & mEnd & "#" & " And Customer = '" & Cust & "'" & " And Source = '" & Src & "'" & " ORDER BY DeliveryDate DESC")

    Set XLWb = ApXL.Workbooks.Open(strPathName)


    With XLWb
    .Worksheets(1).Cells(1) = "PRESS AND HOLD 'CTRL'"
    .Worksheets(1).Cells(2, 1) = "AND PRESS 'F' KEY"
    .Worksheets(1).Cells(3, 1) = "WHEN THE SEARCH BOX APPEARS"
    .Worksheets(1).Cells(4, 1) = "TYPE YOUR SEARCH"
    .Worksheets(1).Cells(1, 3) = "SL-NUMBER"
    .Worksheets(1).Cells(1, 4) = "DEALER"
    .Worksheets(1).Cells(1, 5) = "PO-NUMBER"
    .Worksheets(1).Cells(1, 6) = "LIFT TYPE"
    .Worksheets(1).Cells(1, 7) = "LIFT DETAILS"
    .Worksheets(1).Cells(1, 8) = "STATUS"
    .Worksheets(1).Cells(1, 9) = "DELIVERY"
    .Worksheets(1).Cells(3, 3).CopyFromRecordset rs
    .Worksheets(1).Range("C3:I3").Borders(xlEdgeTop).L ineStyle = xlContinuous
    .Worksheets(1).Cells.EntireColumn.AutoFit
    .Worksheets(1).Cells.EntireColumn.HorizontalAlignm ent = xlLeft
    .Worksheets(1).Cells(3, 9).NumberFormat = "dd-mm-yy" WORKS PERFECT, THE REST OF COLUMN 9 is still NUMBERS

    Can i do something like .Cells(3, 9).Range (rs.recordCount) ????


    Much appreciated

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    set the whole column
    .Worksheets(1).columns("I:I").NumberFormat =...

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    Excellent thank you, that worked a treat, another question, is it easy for Access to add a command button with an input box to search a criteria instead of

    .Worksheets(1).Cells(1) = "PRESS AND HOLD 'CTRL'"
    .Worksheets(1).Cells(2, 1) = "AND PRESS 'F' KEY"
    .Worksheets(1).Cells(3, 1) = "WHEN THE SEARCH BOX APPEARS"
    .Worksheets(1).Cells(4, 1) = "TYPE YOUR SEARCH"
    .Worksheets(1).Cells(1, 3) = "SL-NUMBER"

    for example
    Worksheets(1).Cells(2, 1) = "AND PRESS 'F' KEY" replaced with

    Worksheets(1).Cells(2, 1) = Command button

    then command button onClick >>

    >> Dim MyInput as String
    MyInput = InputBox("Enter Your Search Criteria ?","ENTER SEARCH")

    DoCmd.Find (myInput)

    ?

  4. #4
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    Is there a method that .Worksheets(1).Cells(3, 1) = "WHEN THE SEARCH BOX APPEARS" can be replaced with something like:

    .Worksheets(1).Cells(3, 1) = Application.CommandBars("Edit").Controls("Find") ??

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,776
    You want Access code to add a command button to a worksheet?? That's an odd one for which I won't even ask why rather than using a properly designed worksheet, template or not
    I suspect it's something you're going to have to Google, as did I.
    https://stackoverflow.com/questions/...-to-a-userform
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Clearing and entire column
    By MaineLady in forum Access
    Replies: 2
    Last Post: 07-09-2016, 12:03 PM
  2. Replies: 12
    Last Post: 10-08-2014, 02:35 PM
  3. Replies: 5
    Last Post: 07-17-2014, 09:16 AM
  4. Drop Down Box changes entire column
    By tennisbuck in forum Forms
    Replies: 4
    Last Post: 02-26-2014, 12:23 PM
  5. added text to entire column in the Query
    By Jerseynjphillypa in forum Queries
    Replies: 3
    Last Post: 06-12-2012, 09:39 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