title: do while loop based on a value available in cell (find) in vba
body: <p>Hi i am writing a code in vb to check a particular value in a sheet, if the value is not available then it should go back to another sheet to take new value to find, if the value is found i have to do some operation on that sheet i have the below code to find  the value in the sheet but if i pass the same in a DO WHILE loop as condition it gives a compile error</p>
  
  <p>find vaue code</p>
  
  <pre><code>Selection.Find(What:=last_received, After:=ActiveCell, LookIn:= _
      xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
      xlNext, MatchCase:=False, SearchFormat:=False).Activate
  </code></pre>
  
  <p>could some one please help me to write a code of DO WHILE with the above find in the loop condition so that if the condition gives false (i,e if the value is not found in the sheet) then i should use some other value to find</p>
  
  <p>this is the code that i am going to put in loop</p>
  
  <pre><code>Sheets("Extract -prev").Select
      Application.CutCopyMode = False
  
      ActiveWorkbook.Worksheets("Extract -prev").Sort.SortFields.Clear   'sorting with tickets
      ActiveWorkbook.Worksheets("Extract -prev").Sort.SortFields.Add Key:=Range( _
          "C2:C2147"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
          xlSortNormal
      With ActiveWorkbook.Worksheets("Extract -prev").Sort
          .SetRange Range("A1:AB2147")
          .Header = xlYes
          .MatchCase = False
          .Orientation = xlTopToBottom
          .SortMethod = xlPinYin
          .Apply
      End With
  
  Application.Goto Reference:="R1C3"        'taking last received ticket
      Selection.End(xlDown).Select
      Selection.Copy
      Sheets("Calc").Select
      Application.Goto Reference:="Yesterday_last_received"
      ActiveSheet.Paste
  </code></pre>
  
  <p>this code takes the last ticket but based on it's availablity in next sheet "extract" i have to take one ticket previous to the last one (and on).</p>