Guest User

Untitled

a guest
Apr 26th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. With ThisWorkbook.Worksheets("Sheet1")
  2.  
  3. Dim ar As Variant
  4. Dim i As Integer
  5. Dim j As Long
  6.  
  7. ar = Array("Header1", "Header2") 'define header names to move
  8.  
  9. For i = 0 To UBound(ar)
  10. j = [A1:AW1].Find(ar(i)).Column
  11. Columns(j).Copy Sheet2.Cells(1, i + 1) 'copy to sheet2 from sheet1
  12. Next I
  13.  
  14. End With
  15.  
  16. End Sub
  17.  
  18. j = [A1:AW1].Find(ar(i)).Column
  19.  
  20. Dim f As Range
  21.  
  22. Set f = Range("A1:AW1").Find(arr(i),lookat:=xlwhole)
  23. If Not f Is Nothing Then
  24. f.Entirerow.Copy Sheet2.Cells(1, i + 1)
  25. End If
Add Comment
Please, Sign In to add comment