Guest User

Untitled

a guest
Jul 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. CHM0123456 SRM0123:01
  2. CHM0123456 SRM0123:02
  3. CHM0123456 SRM0256:12
  4. CHM0123456 SRM0123:03
  5. CHM0123457 SRM0789:01
  6. CHM0123457 SRM0789:02
  7. CHM0123457 SRM0789:03
  8. CHM0123457 SRM0789:04
  9.  
  10. =INDEX($C$2:$C$6, SMALL(IF($B$8=$B$2:$B$6, ROW($B$2:$B$6)-MIN(ROW($B$2:$B$6))+1, ""), ROW(A1)))
  11.  
  12. For x = 1 to 6555
  13. if Ax = Chm123456
  14. string = string + Bx
  15. else
  16. next
  17.  
  18. For x = 2 To 6555
  19. If Cells(x, 1).Value = "CHM0123456" Then
  20. outstring = outstring + vbCr + Cells(x, 2).Value
  21.  
  22.  
  23. End If
  24.  
  25.  
  26. Next
  27. MsgBox (outstring)
  28.  
  29. End Function
  30.  
  31. Function ListUnique(ByVal search_text As String, _
  32. ByVal cell_range As range, _
  33. Optional seperator As String = ", ") As String
  34.  
  35. Application.ScreenUpdating = False
  36. Dim result As String
  37. Dim i as Long
  38. Dim cell As range
  39. Dim keys As Variant
  40. Dim dict As Object
  41. Set dict = CreateObject("scripting.dictionary")
  42.  
  43. On Error Resume Next
  44. For Each cell In cell_range
  45. If cell.Value = search_text Then
  46. dict.Add cell.Offset(, 1).Value, 1
  47. End If
  48. Next
  49.  
  50. keys = dict.keys
  51. For i = 0 To UBound(keys)
  52. result = result & (seperator & keys(i))
  53. Next
  54.  
  55. If Len(result) <> 0 Then
  56. result = Right$(result, (Len(result) - Len(seperator)))
  57. End If
  58.  
  59. ListUnique = result
  60. Application.ScreenUpdating = True
  61.  
  62. End Function
  63.  
  64. vData=rUnique
  65.  
  66. dim i as long
  67. dim runique as range, reach as range
  68. dim sData as string
  69. dim vdata as variant
  70.  
  71. set runique=advancedfilter(...) 'Filter in place
  72. set runique=runique.specialcells(xlCellTypeVisible)
  73. for each reach in runique.areas
  74. vdata=reach
  75. for i=lbound(vdata) to ubound(vdata)
  76. sdata=sdata & vdata(i,1)
  77. next l
  78. next reach
  79.  
  80. dim wks as worksheet
  81.  
  82. for each wks in Activeworkbook.Worksheets
  83. if wks.name <> "CopiedToWorksheet" then
  84. advancedfilter(...) 'Copy to bottom of list, so you'll need code for that
  85. end if
  86. next wks
  87. vdata=activeworkbook.sheets("CopiedToWorksheet").usedrange
  88. sData=vdata(1,1)
  89. for i=lbound(vdata) + 1 to ubound(vdata)
  90. sData=sData & ","
  91. next i
  92.  
  93. On Error Resume Next
  94. wks.ShowAllData
  95. On Error GoTo 0
  96. wks.UsedRange.Rows.Hidden = False
  97. wks.UsedRange.Columns.Hidden = False
  98. rFilterLocation.ClearContents
Add Comment
Please, Sign In to add comment