Convert 3 rows cell data to one cell data


#1

i have a data in excel which is like below

apple orange banana

I would like to convert this three row data into

apple,orange,banana

how should i do this?


#2

apple orange banana is written as 3 rows in the first example


#3

apple
orange
banana


#4

to

apple, orange, banana


#5

@Seonyong written in single cell or 3 cells


#6

three cells


#7

hi @Seonyong,

Check this one will help you.

File :RowData.zip (7.3 KB)

Regards
Balamurugan


#8

HI @Seonyong,

This is another way using the for loop.

File :RowData1.zip (7.6 KB)

Regards
Balamurugan


#9

thank you for example but what i wann do is
convert

apple
banana
orange


#10

to

apple, banana, orange


#11

@Seonyong,

Declare a string variable “Valstr”

you can use like this.

Valstr = String.Join(",", arrString)

Ref:

https://www.dotnetperls.com/convert-string-array-string-vbnet

https://www.dotnetperls.com/convert-list-string-vbnet

Regards
Balamurugan


#12

thank you so much i feel like it should work but im keep failing…


#13

Can you share the source if possible ?

Regards
Balamurugan


#14

im sorry i cant but i can explain about it
i have data table which is dtMail
and im using assign as

Example = string.join(",",dtMail)

but im failing


#15

Hi @Seonyong,

You can try like this,

yourStringName = String.Join(",", (From row In dtMail.Rows Select CType(row.Item(“columnname”), String)).ToArray)


#16

Hi @Seonyong

You can use like this.

strValue= string.join(",",dtEmial.Rows.Cast(Of DataRow)().Select(Function(a) a.Field(Of String)(“email”).ToArray()))

Regards
Balamurugan


#17

sorry for bothering again but it became like this

System.Char[],System.Char[],System.Char[],System.Char[]

what should i do from here??


#18

@Seonyong

A bracket is missing.

I have attached the source also.

RowData.zip (2.9 KB)

image


#19

Im sorry to bother u again but actually there is integer inside datatable so there is an error happening as this can only applied to string values. what should i do >?


#20

@Seonyong tell about question clearly or paste screenshot datatable.