Advertisement
Guest User

table1

a guest
Jan 27th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub main()
  2. Dim cell As Range, myCollection As New Collection, el As Variant, x As Range, c As Range, b As Range, num As Range
  3. Dim clmn As Integer
  4. Range("A1:A9").Select
  5. On Error Resume Next
  6. For Each cell In Selection
  7. k = k + 1
  8. myCollection.Add CStr(cell.Value), CStr(cell.Value)
  9. Next cell
  10. On Error GoTo 0
  11.  
  12. Sheets.Add After:=ActiveSheet
  13. ActiveSheet.Name = "Uni"
  14. For Each el In myCollection
  15.     i = i + 1
  16.     Cells(i, 1) = el
  17. Next el
  18.  
  19. For Each c In Worksheets(1).Range("A1:A9")
  20.     For Each cell In Worksheets(2).Range("A1:A" & WorksheetFunction.CountA(Range("A:A")))
  21.         If cell.Value = c.Value Then
  22.             clmn = 1
  23.             Do While Cells(cell.Row, c.Column + clmn) <> ""
  24.                 clmn = clmn + 1
  25.             Loop
  26.             roww = c.Row
  27.             ThisWorkbook.Sheets("Uni").Cells(cell.Row, c.Column + clmn) = roww
  28.         End If
  29.     Next cell
  30. Next c
  31. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement