title: Copy data from one column to another of the same row based on condition using VBA
body: <p>I have an excel file with a worksheet named in-out. In the worksheet, there are 4 columns occupied with data where as two more columns are blanks.</p>
  
  <p>col A : input/output name</p>
  
  <p>col B : input name (blank)</p>
  
  <p>col C : output name (blank)</p>
  
  <p>col D : port-used name</p>
  
  <p>col E : set_input/set_output</p>
  
  <p>col F : value</p>
  
  <p>The task that I need to do is to check on each line from 1 till last (around 90000 lines and going to be increased), if data in col E is equal to set_input, copy data in col A to cell in col B, and if data in col E is equal to set_output, copy data in col A to cell in col B. </p>
  
  <p>May I know how can I start the VBA script, should i start by finding the last row first so that the program will loop till the last used row? Is it possible to check on each line and copy the data based on the condition?</p>
  
  <p>I started writing the script below and I got stuck.</p>
  
  <pre><code>Sub Test()
  
  Dim LastRow As Long
  Dim x As Integer
  
  With Worksheets("in-out")
    LastRow = .Cells(Rows.Count, "E").End(xlUp).Row
      .Range("E2:E" &amp; LastRow).Select
    For x = Range("E2") To LastRow
    If x = "set_input_" Then
  
  End With
  
  End Sub    
  </code></pre>