Results 1 to 4 of 4
  1. #1
    jcbrackett is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    5

    Angry code to delete rows based of empty cells

    I am completely stumped and have searched and searched. I am trying(well can succesfully) import an excel file into an access table. I am stumped on trying to search colum D for blank cells and then delete the whole row. The code i used works for what i currently do and that is delete row 1 then import the file. I want to continue using that by deleting row 1 first then find the blank cells in column d and delete the whole row, then continue with the import. Below is my code i currently have:

    Sub ModTMM()
    Dim oXL As Object
    Dim sFullPath As String

    Set oXL = CreateObject("Excel.Application")
    sFullPath = CurrentProject.Path & "\TMM\CrystalReportViewer1.xls"




    With oXL
    '.ScreenUpdating = False
    .Visible = True
    .Workbooks.Open (sFullPath)


    .DisplayAlerts = False
    .ActiveWorkbook.Sheets(1).Rows(1).Delete
    .ActiveWorkbook.Save
    .Quit
    End With
    ImportTMM
    End Sub

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Sounds very complicated - why not just import the entire file (exclude headings if that is your row 1) and then run a delete query to delete all records where column D is blank (null). Use DoCmd.TransferSpreadsheet

  3. #3
    jcbrackett is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    5
    I would but the problem is that i do not want the data imported as the file grows as the month goes on, becomes quit large and is ALOT of useless data within it at that point.

  4. #4
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    How about checking column d and if NULL, skip that line (don't import it). Don't have to delete the line, just don't import it....
    Last edited by ssanfu; 03-05-2012 at 02:28 PM. Reason: computer can't spell

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

Similar Threads

  1. Vba Code delete&shift up cells- Access 2007
    By Luca87itc in forum Programming
    Replies: 2
    Last Post: 02-08-2012, 02:36 AM
  2. Replies: 4
    Last Post: 11-20-2011, 01:08 PM
  3. Columns, Rows & Cells
    By Paul H in forum Reports
    Replies: 7
    Last Post: 09-21-2011, 12:27 PM
  4. Replies: 7
    Last Post: 09-15-2011, 01:58 PM
  5. Delete cells <= 2 letter values
    By melting in forum Access
    Replies: 5
    Last Post: 05-14-2011, 07:47 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