title: Excel VBA macro: Locating first empty cell in a column and automatically filling it
body: <p>I have two columns, Column (A) and Column (B) in a spreadsheet. </p>
  
  <p>Column (A) contains names extracted from a query (ex. Brian, Bob, Bill, etc...) and column (B) contains one of three statuses (Assigned, In Progress, or Pending). </p>
  
  <p>However, this query sometimes pulls up some line items showing "Assigned" for the status with no name, therefore corresponding cell representing the name in Column (A) is blank. So I manually fill in those empty cells with "Unknown".</p>
  
  <p>What I want to do is to create a macro that finds the every empty cell in column (A) and fill in the word "Unknown" if the cell to its right contains the word "Assinged".</p>
  
  <p><strong>So the conditions are:</strong></p>
  
  <ol>
  <li><p>Blank cell in column (A)</p></li>
  <li><p>Correspoding cell to its right (column B) contains the word "assinged"</p></li>
  </ol>
  
  <p><strong>This is my Code:</strong></p>
  
  <pre><code>Private Sub CommandButton2_Click()
  
      For Each cell In Columns("A")
          If ActiveCell.Value = Empty And ActiveCell.Offset(0, 1).Value = "Assigned" Then ActiveCell.Value = "Unknown"
      Next cell
  
  End Sub   
  </code></pre>