Loop not working properly
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 |
All times are GMT +1. The time now is 07:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com