Loop not working properly

D

Dagonini

I am trying to loop through a file and have each record searched for
information then moved to a new sheet based on the findings.

The macro seems to be working for the first record on the file but it
doesn't seem to be looping through for each record. I'm not sure
where I went wrong in my macro.

Sub life_file()

Set rangetosearch = ActiveSheet.UsedRange
Set cellelement = rangetosearch.Cells

Count = 1

For Each cellelement In rangetosearch

Range("x1") = rangetosearch

If Range("x1").Value Or Range("ae1").Value Or Range("ah1").Value > 0
Then
ActiveCell.EntireRow.Copy
Sheets("LIFE").Select
ActiveSheet.Paste
Sheets("EOI_TEST").Select
ElseIf Range("aa1").Value Or Range("ac1").Value > 0 Then
ActiveCell.EntireRow.Copy
Sheets("LTD_STD").Select
ActiveSheet.Paste
ElseIf Range("x1").Value And Range("ae1").Value And Range("ah1").Value
And _
Range("aa1").Value And Range("ac1").Value > 0 Then
ActiveCell.EntireRow.Copy
Sheets("LIFE").Select
ActiveSheet.Paste
Sheets("LTD_STD").Select
ActiveSheet.Paste
End If

Count = Count + 1
Next

End Sub
 

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

Top