ewaldt at gdls.com
ewaldt at gdls.com
Thu Jul 26 14:34:51 CDT 2007
I wrote the code below, which works really well and I'm very happy with it. This is code for Excel, though. What I need to do is the following: 1. Have the user find the Excel file (I can do this). 2. Have the code below apply to the Excel file (Don't know how to do this from within Access). 3. Have Access run the import process on the new worksheet (Not sure how to have it do that specific sheet; can it work on a workbook already in memory without saving the Excel file first?). 4. Do more processing of the data (I have this set up). So I really need help with #2 and maybe #3 above. Of course #2 is using the Excel object model, and that has to be taken into consideration. Any help? Thanks. Thomas F. Ewald Stryker Mass Properties General Dynamics Land Systems ---------------------------------------------------------- Sub PrepForImport() ' Created 7/26/2007 by ewaldt Dim intLastRow As Integer Dim intCount As Integer Dim intNewRow As Integer Dim oCell As Object Sheets.Add Sheets("Sheet1").Name = "ToImport" Sheets("ToImport").Select 'Copy only rows where column B = "A" intNewRow = 1 For Each oCell In Sheets("GDLS-SHC").Range("B:B") If oCell.Formula = "A" Then oCell.EntireRow.Copy ActiveSheet.Paste Destination:=Worksheets("ToImport").Range("A" & intNewRow) intNewRow = intNewRow + 1 End If Next oCell For Each oCell In Sheets("GDLS-C").Range("B:B") If oCell.Formula = "A" Then oCell.EntireRow.Copy ActiveSheet.Paste Destination:=Worksheets("ToImport").Range("A" & intNewRow) intNewRow = intNewRow + 1 End If Next oCell 'Check for non-numeric in Pounds and Grams For Each oCell In Sheets("ToImport").Range("C1:D" & intNewRow - 1) If Not IsNumeric(oCell.Formula) Then oCell.Formula = 0 End If Next oCell End Sub This is an e-mail from General Dynamics Land Systems. It is for the intended recipient only and may contain confidential and privileged information. No one else may read, print, store, copy, forward or act in reliance on it or its attachments. If you are not the intended recipient, please return this message to the sender and delete the message and any attachments from your computer. Your cooperation is appreciated.