Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

How to process lines of data in clipboard

say data of following is as below:

00195  10,000   0.370 3,700.00      
00309  100,000  0.216 21,600.00      
00312  4,000  0.720 mydata      
00317  2,600  6.650 17,290.00      
00460  1,000  3.360 3,360.00      
01086  1,000  3.860 3,860.00      
01157  520  10.460 5,439.20  

Action: select above data, copy into clipboard

How to use Excel Macro VBA to read the data in the clipboard and process lines of data one by one

Dim DataObj As New MSForms.DataObject
Dim s As String
     
DataObj.GetFromClipboard
s = DataObj.GetText
MsgBox s
'
'Pseudo code needed
'
for each line in reading s
      print line
next

Warning: the data for each line is separated by LF or Carriage Return
0
tindavid
Asked:
tindavid
1 Solution
 
tindavidAuthor Commented:
Ooops find the solution myself.

       Dim DataObj As New MSForms.DataObject
       Dim s As String
       Dim str() As String
       Dim idx As Integer
       Dim data_line As String
       
       DataObj.GetFromClipboard
       s = DataObj.GetText
       idx = 0
       str() = Split(s, vbLf)
       Do While Not str(idx) = Empty
          MsgBox str(idx)
          idx = idx + 1
       Loop
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now