title: VBA Excel. How to search for a value, get the first row/first column values and insert them in a different sheet if they don't yet exist
body: <p>I have a workbook for project tracking with two sheets. Sheet1 is the overview and Sheet2 is for involvement.
  I need a code to do the following:
  1. Find the "x" used to mark a person as assigned to a project
  2. Get the project name
  3. Go to Sheet2, lookup the person with the project, and if the project is not there, insert it</p>
  
  <pre><code>Public Sub CommandButton2_Click()
  Application.ScreenUpdating = False   'Turn off screen updating
  Dim searchSheet1 As Range
  Dim name As String
  Dim searchSheet2 As Range
  Worksheets("Sheet1").Activate
  Set searchSheet1 = Range("D4", "S60") 'defined a larger area...
  For Each cell In searchSheet1
  If InStr(1, cell.Value, "x") &gt; 0 Then
  name = Cells(searchSheet1.Column).Text 'name that is assigned on project
  'find the project to copy - row/column
   Range("A" &amp; searchSheet1.Row, "B" &amp; searchSheet1.Row).Select
   Range("A" &amp; searchSheet1.Row, "B" &amp; searchSheet1.Row).Copy
  'search in Sheet2 for the name and project
  Worksheets("Sheet2").Activate
  '''''''If I use For again I get an error
  
  'Inserting command
   Selection.Insert Shift:=xlDown
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rGcTg.png" rel="nofollow noreferrer">sheet1</a>
  <a href="https://i.stack.imgur.com/KlNvY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KlNvY.png" alt="Sheet2"></a></p>
  
  <p>This is what I was able to do... But I got stuck...
  If anybody could help me out I would appreciate it
  Thank you</p>