Generating a List of Values in Excel (VBA)

This post was previously released under a different blog and is being republished by me below. That site is no longer available. I am the original author.

I frequently find myself needing to create lists of values I have in Excel in one cell. For example, I might get have a column of IDs and I need to create a comma delimited list of them to put into a SQL Query. I have the following function I put in an XLA that loads with Excel to generate these lists.

Now in any cell I can enter something like =GenerateList(A1:A250,”;”) and have a semi-colan delimited list of the values in cells A1 – A250. If you cannot tell from the function, if you do not include a delimiter parameter (the second one), it will default to “comma space”.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.