ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create Variable Length String Dependent Upon Size List (https://www.excelbanter.com/excel-programming/362659-create-variable-length-string-dependent-upon-size-list.html)

ags5406

Create Variable Length String Dependent Upon Size List
 
I want to create a string that depends on the number of items in a
list.

For example, say my list looks like the following:

(a1) baseball
(a2) football
(a3) basketball
(a4) hockey
(a5) lacrosse
(a6) soccer

The string that I want will be:

John Doe plays baseball, football, basketball, hockey, lacrosse, and
soccer.

I could just use:

string = "John Doe plays " & A1 & ", " & A2 & ", " & A3 & ", " & A4 &
", " & A5 & ", " & A6 &"."

But the trick is that I won't know ahead of time how many items are in
the list. For one guy it might be three sports in the list and for
another it might be five.

Can I somehow use for/next to create the string with different numbers
of items????

Thx in advance.


JethroUK©

Create Variable Length String Dependent Upon Size List
 
whether the guy has 3 sports or 6 - your existing formula will produce right
answer


"ags5406" wrote in message
oups.com...
I want to create a string that depends on the number of items in a
list.

For example, say my list looks like the following:

(a1) baseball
(a2) football
(a3) basketball
(a4) hockey
(a5) lacrosse
(a6) soccer

The string that I want will be:

John Doe plays baseball, football, basketball, hockey, lacrosse, and
soccer.

I could just use:

string = "John Doe plays " & A1 & ", " & A2 & ", " & A3 & ", " & A4 &
", " & A5 & ", " & A6 &"."

But the trick is that I won't know ahead of time how many items are in
the list. For one guy it might be three sports in the list and for
another it might be five.

Can I somehow use for/next to create the string with different numbers
of items????

Thx in advance.





All times are GMT +1. The time now is 07:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com