Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

How to concatenate in excelvba

  Asked By: Mada    Date: Nov 13    Category: MS Office    Views: 703
  

Can anyone suggest how can I write a script in VBA that has:

data:

dog (white)
dog (brown)
cat
rabbit



and my desired output based on the data is like:

dog,cat,rabbit

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Emma Brown     Answered On: Nov 13

To write  this macro you will need a "for next" loop to step through the cells

Within this macro you will need to set a variable equal to the contents of the
cell.

You then need to use the left function to extract the part of the cell before
the (

But then check whether the value is the same as the previous value.

If it is not the same concatenate  the value to the string you are building.

X equals X & myValue


Have a go at this and let us know if you have any problems.

 
Didn't find what you were looking for? Find more on How to concatenate in excelvba Or get search suggestion and latest updates.




Tagged: