title: VBA - Copy a specific headers from a sheet to another
body: <p>I try to copy the headers who have the cell below with "mandatory" value but my Macro stop at the first cell.
  Name   Phone  Houe no    Locality
  mandatory   mandatory</p>
  
  <pre><code>  Dim i As Long, j As Long, Lastrow1 As Long, Lastcol1 As Long
  Dim mandatory As String
  
  'Lastrow1 = Sheets("sheet3").Range("A" &amp; Rows.Count).End(xlUp).Row
  Lastcol1 = Sheets("sheet3").Cells(1 &amp; Columns.Count).End(xlToLeft).Column
  For i = 1 To Lastcol1
  
  Sheets("sheet4").Activate
  Lastcol2 = Sheets("sheet4").Cells(1 &amp; Columns.Count).End(xlToLeft).Column
  For j = 1 To Lastcol2
  
  If Sheets("sheet3").Cells(2, i).Value = "mandatory" Then
  Sheets("sheet3").Activate
  Sheets("sheet3").Cells(i, "A").Copy
  Sheets("sheet4").Activate
  Sheets("sheet4").Cells(j, "A").Select
  ActiveSheet.Paste
  End If
  
  Next j
  
  Application.CutCopyMode = False
  Next i
  Sheets("sheet3").Activate
  Sheets("sheet3").Range("A1").Select
  
  
  End Sub
  </code></pre>