Delete rows from outside of Excel application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a workbook with several worksheets each containing Column D as a Date.
I need to be able to delete any rows with a date earlier than Now(). I
would like to be able to do that from Access if possible.
If I need to add a control to Excel, please include code for that control.

Thank you.
 
A starter

set xlApp = GetObject(,"Excel.Application")
with xlapp.Activesheet
cLastRow = .Cells(.Rows.Count,"D").End(xlUp).Row
For i = cLastRow To 1 Step -1
if .Cells(i,"D").Value = Date Then
.Cells(i,"D").Entirerow.Delete
End If
Next i
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
I'll give this a try, but how do I move to the next worksheets to do the same
thing
 
SOmething like

Set xlApp = GetObject(, "Excel.Application")
With xlApp
For Each oWS In xlApp.Workbooks("Personal.xls").Worksheets
cLastRow = oWS.Cells(oWS.Rows.Count, "D").End(xlUp).Row
For i = cLastRow To 1 Step -1
If oWS.Cells(i, "D").Value = Date Then
oWS.Cells(i, "D").EntireRow.Delete
End If
Next i
Next oWS
End With


juust replace the workbook name with your name

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top