Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
systemx
 
Posts: n/a
Default How do I create a list of items in a column?


Hi,

The long way of doing this is -

=A1&","&A2&","&A3

and so on for all values. If there are not too many values and this is
a realtively short list....then this would probably be fine.

Alternatively, you could write a macro to do it for you - I'm not sure
exactly what it would look like but in (almost) plain english...

Dim MyString As String
Dim NextCell As String

Do

MyString = ActiveCell.Value
NextCell = ActiveCell.Offset(1,0).Value

MyString = MyString &","& NextCell

Until NextCell = ""

Well...someone will get the idea of what I am trying to achieve
there....I don't know much vba so my apologies.

I also think there are character limits on excel cells (about 255 from
memory). Although you can get more in there with 'memo' type cells...I
think you can have problems getting the data back out of Excel.

Good luck

Rob


--
systemx
------------------------------------------------------------------------
systemx's Profile: http://www.excelforum.com/member.php...o&userid=29254
View this thread: http://www.excelforum.com/showthread...hreadid=539485

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ken Johnson
 
Posts: n/a
Default How do I create a list of items in a column?

Hi stepaim,

you could try this macro...

Public Sub List()
Dim iLastRow As Long
Dim I As Long
Dim strList As String
iLastRow = Range("A" & Range("A:A").Rows.Count).End(xlUp).Row
For I = 1 To iLastRow
If Cells(I, 1).Value < "" Then
strList = strList & Cells(I, 1).Value & ", "
End If
Next
If Right(strList, 2) = ", " Then
Let Cells(1, 2).Value = Left(strList, Len(strList) - 2)
Else: Let Cells(1, 2).Value = strList
End If
Cells(1, 2).EntireColumn.AutoFit
End Sub

If any cells in column A between A1 and the bottommost value is a blank
then it is not included in the list that is placed in B1.
If you want blanks included then use...

Public Sub List()
Dim iLastRow As Long
Dim I As Long
Dim strList As String
iLastRow = Range("A" & Range("A:A").Rows.Count).End(xlUp).Row
For I = 1 To iLastRow
strList = strList & Cells(I, 1).Value & ", "
Next
Let Cells(1, 2).Value = Left(strList, Len(strList) - 2)
Cells(1, 2).EntireColumn.AutoFit
End Sub


Ken Johnson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I create a dependent list, to a current list? elevenphil Excel Discussion (Misc queries) 1 January 30th 06 04:35 PM
Need to Improve Code Copying/Pasting Between Workbooks David Excel Discussion (Misc queries) 1 January 6th 06 03:56 AM
creating a bar graph Johnfli Excel Discussion (Misc queries) 0 October 26th 05 08:16 PM
Compare 2 columns, and create a list of items that are in both lists ruby2sdy Excel Worksheet Functions 3 October 8th 05 11:04 AM
named range, data validation: list non-selected items, and new added items KR Excel Discussion (Misc queries) 1 June 24th 05 05:21 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"