Solved

How to process lines of data in clipboard

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel for Mac - How make those Tabs larger? 2 31
Export Query data to excel file 14 39
Delete Text 7 46
Get the last column in excel range 6 19
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

863 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

24 Experts available now in Live!

Get 1:1 Help Now