View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Loop Through Text and Test for Scenarios Q

hi Sean,

Am Mon, 5 Aug 2013 07:42:05 -0700 (PDT) schrieb :

Thanks for your reply. What I meant in e.g. 3 the cell contents in ColC could be "BOD 123456 12345678" <- As you can see I've 2 numeric values separated by a space, first has 6 numerics and the 2nd has 8 numerics


try:
Sub Test()
Dim c As Range
Dim LRow As Long
Dim i As Integer
Dim myArr As Variant
Dim myStr As String
Dim firstaddress As String

myArr = Array("ABC", "Credit Transfer", "BOD")
LRow = Cells(Rows.Count, 3).End(xlUp).Row
For i = LBound(myArr) To UBound(myArr)
Set c = Range("C1:C" & LRow).Find(myArr(i), _
LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
firstaddress = c.Address
Do
If Len(c.Offset(, 1)) = 0 And c.Offset(, 2) 0 Then
Select Case myArr(i)
Case "ABC"
myStr = "Job Done"
Case "Credit Transfer"
myStr = "Job Not Done"
Case "BOD"
myStr = "Job Pending"
End Select
c.Offset(, 5) = myStr
End If
Set c = Range("C1:C" & LRow).FindNext(c)
Loop While Not c Is Nothing And c.Address < firstaddress
End If
Next
End Sub

Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2