Solved

How to process lines of data in clipboard

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
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…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

740 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