First, using Excel 2010.
Second, the raw data I'm looking at is similar to this:
0001 AUT123
0002 LIF654 LIF987
0003 AUT985 LIF456
The output I want is for all LIF elements to be reported in a nice table like this:
0002 LIF654
0002 LIF987
0003 LIF456
As you can see, the first one was skipped because it does not have LIF. The second is supposed to report on 2 different rows, splitting the two LIF values. The third reports the 2nd element....
Currently, this is the code I have in my macro:
Sub LifeOnly1()
'
' LifeOnly1 Macro
'
'
'n = active cell offset
'a = offset for copying customer information for each policy
Dim n As Integer
Dim a As Integer
Sheets("LifeOnly").Select
Range("A2:AK1000000").Clear
Range("A2").Select
Sheets("CSVImport").Select
Range("A2").Select
n = 10
FindLif:
If Left(ActiveCell.Offset(0, n), 3) = "LIF" Then
'Client Reference Copy
a = 0
ActiveCell.Offset(0, a).Copy
Sheets("LifeOnly").Select
ActiveCell.Offset(0, a).PasteSpecial
'Copy remainder of Customer Information
Do Until a = 8
a = a + 1
Sheets("CSVImport").Select
ActiveCell.Offset(0, a).Copy
Sheets("LifeOnly").Select
ActiveCell.Offset(0, 1).PasteSpecial
Loop
'Copy Active Remit Cell into LifeOnly
Sheets("CSVImport").Select
ActiveCell.Offset(0, n).Copy
Sheets("LifeOnly").Select
ActiveCell.Offset(0, 1).PasteSpecial
End If
n = n + 2
Sheets("CSVImport").Select
If ActiveCell.Offset(0, n) = Empty Then
ActiveCell.Offset(1, 0).Activate
If ActiveCell.Offset(0, 0) = Empty Then
GoTo EndLoop
End If
GoTo FindLif
End If
EndLoop:
Sheets("LifeOnly").Select
End Sub
What it is doing is that it picks up the first LIF for 0002 and puts it in BUT THEN it overwrites that with the second LIF for 0002 - it needs to shift down to the next row and copy it over but its not working.
Help :/
Bookmarks