Results 1 to 7 of 7
  1. #1
    chr1stoper1 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    55

    macro auto filling

    Hi guys I have a question regarding a macro I have currently running on my data base. Firstly the spread sheet I upload onto my access data base daily does not have the date on it so I manually fill this in on the first column then the macro auto fills it down the sheet to a count that is in the macro. In this macro it also auto fills in any blank boxes in column 2 and replaces the blank with the number from the box above it .
    The problem is this is a daily sheet and it never has the same amount of rows so Im always having to add or remove dates. I was wondering how I would go about getting the macro to auto fill column 2 with the number from above and then recognise that the amount of rows to auto fill with the date in column 1 is the last row in column 2?
    Also is there a way to auto add date into the macro ? so I only have to click the macro and it auto fills all the above?
    Your help is always appreciated
    [Sub FillDate()
    '
    ' Macro1date Macro


    'Dim WkRg As Range
    Dim F As Range
    Set WkRg = Range("B2:B" & Range("C" & Rows.Count).End(xlUp).Row)
    WkRg.Select
    For Each F In WkRg
    If F = "" Then F = F.Offset(-1, 0)
    Next '
    Range("A2").Select
    Selection.Copy
    Range("A3").Select
    ActiveSheet.Paste
    Range("A2:A3").Select
    Application.CutCopyMode = False
    Selection.AutoFill Destination:=Range("A2:A45"), Type:=xlFillDefault
    Range("A2:A45").Select

    End Sub
    ]

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    This looks like an Excel macro. But here in the Access forum, we run queries to fill in data.
    Do you want to fill in the data in excel, or AFTER you bring into access?
    An update query in a macro can correct all this.

  3. #3
    chr1stoper1 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    55
    Yeah this macro is an excel macro and I currently update this then upload it into my data base Ive never used the update query yet so I will look into it thanks

  4. #4
    chr1stoper1 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    55
    I would like the best way to do it really either before or after

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    Options:

    1. before importing Excel code populates cells with date value - review http://stackoverflow.com/questions/2...xcel-using-vba

    2. after importing and the date field is null, run an UPDATE action: UPDATE tablename SET fieldname = Date() WHERE fieldname Is Null
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    chr1stoper1 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    55
    Hi ive not come across update action yet . I know you can update a query or run a query update but I'm uploading to a table . Sorry if this is simple but ive not come across it yet

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    My suggestion is to import the data then run an UPDATE action.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Auto-filling data
    By Ranger7913 in forum Programming
    Replies: 3
    Last Post: 01-12-2015, 03:26 PM
  2. Replies: 5
    Last Post: 08-28-2012, 03:23 PM
  3. Auto filling a form from table
    By JoScSM in forum Forms
    Replies: 1
    Last Post: 11-02-2010, 08:09 AM
  4. Auto Filling
    By tgavin in forum Forms
    Replies: 2
    Last Post: 08-02-2010, 10:47 AM
  5. Auto filling form fields
    By adamch29 in forum Forms
    Replies: 1
    Last Post: 07-25-2007, 06:22 PM

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