-2

In excelsheet I have 500 records with 50 or more columns. I need to check for all the columns for which the cell value is yes, add that column heading to a string separated by semicolon in the respective row. for eg :

Delhi   Jaipur  Basel   Colombia    Peris   London  Dubai   Munich   List
no      no      yes     yes         no      no      no      yes     Basel;Munich
yes     no      no      no          no      no      yes     no      Delhi;Dubai
no      no      no      no          no      no      no      no  
no      no      yes     yes         no      no      no      no      Basel;Colombia

Any input is appreciated.

Grade 'Eh' Bacon
  • 3,773
  • 4
  • 24
  • 46
Mams P
  • 1
  • Possible duplicate of [Concatenate top row cells if column below has 1](http://stackoverflow.com/questions/28679758/concatenate-top-row-cells-if-column-below-has-1/28680713#28680713). –  Mar 03 '16 at 19:36

1 Answers1

0

Try:

Dim answer as String
For i=2 to Range("A1").End(xlDown).Row
   answer=""
   For j=1 to 8
      If Cells(i,j)="yes" then
         answer=answer & Cells(1,j).Value & ";"
      End if
   Next j
   Cells(i,9)=answer
Next i

Note that this works for your example only, you need to check the column numbers.

N. Pavon
  • 821
  • 4
  • 15
  • 32