-1

I would like a range most varying say A1:A20 pulled from an application with space in beginning or in end so it need to be TRIM and then Remove Duplicates, remove blank cells and they need to be TEXTJOIN(",",TRUE,A1:A20). Range is variable. So that I can copy paste this to QMF for running query.

Appreciate your help in creating this VBA so that I can create a button in the ribbon and can use in any excel sheet.

Greenonline
  • 1,330
  • 8
  • 23
  • 31

1 Answers1

0
 Sub removeDuplicate()
 'removeDuplicate Macro

 Columns("A:A").Select
 ActiveSheet.Range("$A$1:$A$20").RemoveDuplicates Columns:=Array(1), _ 
 Header:=xlNo 
 Range("A1").Select

 End Sub
  • Above provided vba only remove duplicate but does not TRIM nor remove blank cells nor do the textJoin the range. Also the range may not be in column (A:A) .Can be in any column by users selection of range.Appreciate an answer which should include these multiple criteria.. – Biju Jacob Apr 22 '19 at 14:08