Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Convert CSV from clipboard into a transposed list (part solution provided)

I am trying to convert a list of comma seperated numbers into a list that is
pasted with each number in an individual cell.

E.g. 125,25,223,23,35,23

would be pasted to

125
25
223
23
35
23

I have managed to convert the CSV into a list of numbers but can only paste
the entire list into 1 cell. Can someone tell me how I would modify it so
that each number is in a single cell.

It will need a reference to the MS Forms library.

Here's what I have so far:-

Sub Test1()
Dim myVar As Variant
Dim MyDataObj As New DataObject

myVar = GetOffClipboard
ClearClipboard

myVar = Replace(myVar, ",", Chr(10), 1)
myVar = Replace(myVar, Chr(13), "", 1)
myVar = Replace(myVar, Chr(10) & Chr(10), Chr(10), 1)
myVar = Replace(myVar, " ", "", 1)
Debug.Print myVar

'Print_Chars (myVar)
MyDataObj.SetText myVar
ActiveCell.Value = myVar
End Sub


TIA Andi


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Convert CSV from clipboard into a transposed list (part solution provided)

'####################################
Sub tester()

Dim arrvar
Dim myVar As String

myVar = "1,2,3,4,5,6,7,8"

arrvar = Split(myVar, ",")

ActiveCell.Resize(UBound(arrvar) + 1, 1).Value = _
Application.Transpose(arrvar)

End Sub
'##################################
--
Tim Williams
Palo Alto, CA


"Andibevan" wrote in message ...
I am trying to convert a list of comma seperated numbers into a list that is
pasted with each number in an individual cell.

E.g. 125,25,223,23,35,23

would be pasted to

125
25
223
23
35
23

I have managed to convert the CSV into a list of numbers but can only paste
the entire list into 1 cell. Can someone tell me how I would modify it so
that each number is in a single cell.

It will need a reference to the MS Forms library.

Here's what I have so far:-

Sub Test1()
Dim myVar As Variant
Dim MyDataObj As New DataObject

myVar = GetOffClipboard
ClearClipboard

myVar = Replace(myVar, ",", Chr(10), 1)
myVar = Replace(myVar, Chr(13), "", 1)
myVar = Replace(myVar, Chr(10) & Chr(10), Chr(10), 1)
myVar = Replace(myVar, " ", "", 1)
Debug.Print myVar

'Print_Chars (myVar)
MyDataObj.SetText myVar
ActiveCell.Value = myVar
End Sub


TIA Andi




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Convert CSV from clipboard into a transposed list (part solution provided)

Thanks Tim - that worked great

"Tim Williams" <timjwilliams at gmail dot com wrote in message
...
'####################################
Sub tester()

Dim arrvar
Dim myVar As String

myVar = "1,2,3,4,5,6,7,8"

arrvar = Split(myVar, ",")

ActiveCell.Resize(UBound(arrvar) + 1, 1).Value = _
Application.Transpose(arrvar)

End Sub
'##################################
--
Tim Williams
Palo Alto, CA


"Andibevan" wrote in message

...
I am trying to convert a list of comma seperated numbers into a list

that is
pasted with each number in an individual cell.

E.g. 125,25,223,23,35,23

would be pasted to

125
25
223
23
35
23

I have managed to convert the CSV into a list of numbers but can only

paste
the entire list into 1 cell. Can someone tell me how I would modify it

so
that each number is in a single cell.

It will need a reference to the MS Forms library.

Here's what I have so far:-

Sub Test1()
Dim myVar As Variant
Dim MyDataObj As New DataObject

myVar = GetOffClipboard
ClearClipboard

myVar = Replace(myVar, ",", Chr(10), 1)
myVar = Replace(myVar, Chr(13), "", 1)
myVar = Replace(myVar, Chr(10) & Chr(10), Chr(10), 1)
myVar = Replace(myVar, " ", "", 1)
Debug.Print myVar

'Print_Chars (myVar)
MyDataObj.SetText myVar
ActiveCell.Value = myVar
End Sub


TIA Andi






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
Display part of list dependant on Validation list selection Jules73 Excel Worksheet Functions 0 August 12th 09 02:21 PM
I am looking for a solution to convert a pdf to excel dcraig Excel Discussion (Misc queries) 1 March 6th 09 12:26 AM
OLD PROBLEM without SOLUTION , part || ytayta555 Excel Worksheet Functions 1 July 8th 08 03:57 PM
Convert VBA solution to a formula Toppers Excel Discussion (Misc queries) 2 June 22nd 06 09:45 PM
I need to convert name 3 part name into Last, First MiddleNameorMI Krexroth Excel Discussion (Misc queries) 5 January 7th 05 10:13 PM


All times are GMT +1. The time now is 07:35 PM.

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"