LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default parsing a column of data into a single entry separated by commas

Inside the loop, check each cell using the InStr function. Something like
this...


If InStr(TheValueFromCell, "@") 0 Then 'It's likely an email address

--
Rick (MVP - Excel)


"ssylee" wrote in message
...
Thanks for your help. This is the code that I have adapted so far:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 8/19/2008 by Stanley Lee
'

'
Dim endrow As Integer
Dim i As Long
Dim receive As String

Range("A6").Select
Selection.End(xlDown).Select

' Obtain the current cell number

endrow = ActiveCell.Row

' Add the comma from the first name to the second last name
'For i = 6 To endrow - 1

With Worksheets("Members")
receive = .Cells(6, 4).Value
For i = 7 To endrow
receive = receive & "," & .Cells(i, 4).Value
Next i
End With

MsgBox receive

End Sub

However at row 36, I have a value that doesn't resemble an email
address. It looks something like #VALUE!

I'm planning to check the validity of the entry by finding if there's
a "@" character in the list, or if there's a robust way of checking
the value. How would I go about to check the type of value entered in
a cell with standard functions in VBA?

On Aug 19, 10:14 am, "Rick Rothstein \(MVP - VB\)"
wrote:
Something like this maybe....

Dim X As Long
Dim LastRow As Long
Dim Answer As String
With Worksheets("Sheet1")
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
For X = 1 To LastRow
Answer = Answer & ", " & .Cells(X, "A").Value
Next
End With
MsgBox Answer

Rick

"ssylee" wrote in message

...

What would be the easiest way perhaps in a for loop in a macro that
would parse from the first row in a column to the last row in the same
column into Cells(row1), Cells(row2), ... , Cells(row n)?




 
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
Sort data separated by commas dab Excel Worksheet Functions 4 May 14th 10 12:53 AM
Compare two files and update data from another file base on words ina cell separated by commas mishak Excel Worksheet Functions 0 December 9th 09 01:35 AM
Reversing the order of data separated by commas within a cell? rome330 Excel Discussion (Misc queries) 5 February 9th 09 07:21 PM
text parsing/table creation from single column data cruiser Excel Discussion (Misc queries) 1 October 24th 07 12:19 PM
parsing words in a cell separated by commas spjoseph0511[_4_] Excel Programming 2 December 16th 03 09:19 PM


All times are GMT +1. The time now is 07:52 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"