Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Need Help Looping through a file


She said

the numbers in Columns X, AE, AH are Life volume coverages. If any one of
those fields is filled in with a volume then I need the record to be copied
to the LIFE spreadsheet. For example in the first record on the test file
column X has 210000. that means that the entire row needs to be copied to
the LIFE spreadsheet. That row also has 60 in column AA (which is STD) so
it needs to also be moved to the LTD_STD spreadsheet.

The second record has X empty but there is 55000 in column AE so it also
needs to be moved to the LIFE spreadsheet. There is also a 60 in column AC
so the record needs to go to the LTD_STD spreadsheet.

I sent this to copy to one or both as indicated from above
x,ae,ah to life
aa,ac to the other
if both, then both

Sub life_fileDON()
Dim LastRow As Long
Dim i As Long

'clear destination rows
rowlife = Sheets("LIFE").Cells(Rows.Count, 1).End(xlUp).Row + 1
Sheets("LIFE").Rows("1:" & rowlife).ClearContents
rowltd = Sheets("LTD_STD").Cells(Rows.Count, 1).End(xlUp).Row + 1
Sheets("LTD_STD").Rows("1:" & rowltd).ClearContents

With Sheet1
LastRow = .Cells(.Rows.Count, "X").End(xlUp).Row
For i = 1 To LastRow

rowlife = Sheets("LIFE").Cells(Rows.Count, 1).End(xlUp).Row + 1
rowltd = Sheets("LTD_STD").Cells(Rows.Count, 1).End(xlUp).Row + 1
If .Cells(i, "X").Value 0 Or _
.Cells(i, "AE").Value 0 Or _
.Cells(i, "AH").Value 0 Then
.Rows(i).Copy Sheets("LIFE").Cells(rowlife, 1)
End If

If .Cells(i, "AA").Value 0 Or _
.Cells(i, "AC").Value 0 Then
.Rows(i).Copy Sheets("LTD_STD").Cells(rowltd, 1)
End If

Next i
End With

End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
If desired, send your workbook to my address below along with snippets of
these msgs, a clear explanation of what you want and examples of
before/after

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Dagonini" wrote in message
...
When I try using Bob's it still only pastes the last row on the file
into a new spreadsheet. I



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
About my looping jonathan Excel Programming 3 July 31st 07 02:48 PM
Looping through folders and using the first file in each folder Conan Kelly Excel Programming 2 September 28th 06 04:23 AM
Looping Gusset Gadder Excel Programming 2 December 11th 04 09:16 PM
Looping René Excel Programming 6 May 28th 04 02:14 PM
Looping though *.xls files except for the main consolidation file Thomas[_14_] Excel Programming 5 April 28th 04 04:17 PM


All times are GMT +1. The time now is 07:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"