View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default Loop through range and add each cell contents to a string

dim myRange as range, r as range
dim aWS as worksheet
Dim myString as string

set aWS = activesheet

myString = ""
set myRange = aWS.range("A1:A100")
for each r in myrange
if not isempty(r) then
mystring = mystring & ";" & r.value
end if
next r






next r

"Daveo" wrote:

Hi there,

Say I have a range A1:A100. How, when clicking a command button, do I
get excel to loop through the range adding the contents into a string
with a colon between each entry?

e.g.

A
1
2

3

4


Becomes ;pete@pete .com"


Many thanks,

David