Solved

How to process lines of data in clipboard

Posted on 2013-01-29
1
481 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
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now