Way out of my element (1 Viewer)

cfp76

Registered User.
Local time
Today, 03:43
Joined
Aug 2, 2001
Messages
42
OK - I'm trying to write a module (have had a little help from someone here but still kinda lost)...

What I have is this

0001 LIF123 LIF234
0002 AUT654 LIF987
003 AUT548

I want:
0001 LIF123
0001 LIF 234
002 LIF987

So my macro is going to check the first cell and see if it contains LIF and move on if it does not and continue until the next is blank (like you see in 0003 there is only one item).

If LIF exists, then write the number and move down.. if it does not exist, either move to the next cell over OR to the next record if that next cell is blank.

I *think* I have most of it but its not working - stupidly, its because of me looking for "LIF" in the cell.. I know this is the reason it won't work BUT its because I am using every other language on trying to find out if a cell starts with or contains LIF as text inside the string. Help me :( I feel like a yutz.

Sub LifeOnly1()
'
' LifeOnly1 Macro
'

'
Dim n As Integer
Sheets("CSVImport").Select
Range("A2").Select

n = 10

FindLif:
If ActiveCell.Offset(0, n).Contains("LIF") Then
Selection.ActiveCell.Offset(0, n).Select
Selection.Copy
Sheets("LifeOnly").Select
ActiveCell.Paste
ActiveCell.Offset(1, 0).Activate
End If
n = n + 2
If ActiveCell.Offset(0, n) = "" Then
If ActiveCell.Offset(1, 0) = "" Then
GoTo EndLoop
End If
ActiveCell.Offset(1, 0).Activate
n = 10
GoTo FindLif
End If


EndLoop:

End Sub
 

Users who are viewing this thread

Top Bottom