Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to process lines of data in clipboard

Posted on 2013-01-29
1
Medium Priority
?
532 Views
Last Modified: 2013-01-29
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
Comment
Question by:tindavid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
tindavid earned 0 total points
ID: 38834023
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question