View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim May Jim May is offline
external usenet poster
 
Posts: 477
Default How to pass selected cells into a delimited text string?

After Filtering - Highlight your Hostname Data Only Cells and run:

Sub extractdata()
Dim mystring As String
ct = Selection.Count
With Selection
For j = 1 To ct
If Selection(1) = Selection(j) Then
mystring = Selection(j).Value
Else
mystring = mystring & "," + Selection(j).Value
End If
Next j
End With
Range("G2").Value = mystring ' Or someother cell <<< chg accordingly,,,
End

That should get you there

"PcolaITGuy" wrote:

I have a spreadsheet of server information with a column called HOSTNAME
where the values are unique and I have other columns such as ENVIRONMENT,
CATEGORY, etc that are used to identify the servers function, location, etc.
Typically I only look at a specific group of servers based on their
ENVIRONMENT or CATEGORY by using an AUTOFILTER.

Having said that, after I have filtered my data showing only the rows I want
I will often select a group of cells under the HOSTNAME column to be used in
other documents, etc. Once I make my selection of cells,Is there a way to
pass the values of these cells into a delimited text string or text file?

Example of selected sells in HOSTNAME column:

HOSTNAME
server1
server2
server6
server9
server33

Pass the values into a string or text file as such:
server1, server2, server6, server9, server33

Thanks in advance for your advice,

Scott