Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default How to pass selected cells into a delimited text string?

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
bta bta is offline
external usenet poster
 
Posts: 3
Default How to pass selected cells into a delimited text string?

Const CF_TEXT As Long = 1



Private Function HostNameList() As String

Dim HostName As Range


For Each HostName In ActiveWindow.RangeSelection
HostNameList = HostNameList & "," & HostName.Value
Next

HostNameList = Mid(HostNameList, 2)
Call PutCFTEXTStringOnClipboard(HostNameList)
End Function



' Requires the reference "Microsoft Forms 2.0 Object Library"
' Just add a UserForm object and delete it again immediately.
Private Sub PutCFTEXTStringOnClipboard(ByRef CF_TEXT_string As String)

Dim ClipboardText As New DataObject


Call ClipboardText.SetText(CF_TEXT_string, CF_TEXT)
Call ClipboardText.PutInClipboard
End Sub

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
converting line-delimited text into cells Wowbagger New Users to Excel 2 April 29th 10 04:19 PM
Sum delimited values in text string if... J Excel Worksheet Functions 7 February 24th 07 06:10 PM
Convert column data to semicolon delimited text string Richard RE Excel Worksheet Functions 1 September 5th 06 03:03 PM
Extracting Numeric Data from a Delimited Text String [email protected] Excel Worksheet Functions 5 February 10th 06 10:29 PM
Why can't I Export selected cells to tab-delimited text file? JE McGimpsey Excel Discussion (Misc queries) 1 November 28th 05 05:33 PM


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