?
Solved

Copy into the clipboard and paste from clipboard into cell of currently selected table.

Posted on 2011-02-14
14
Medium Priority
?
276 Views
Last Modified: 2012-05-11
Dear Experts:

I would like to incorporate two code snippets in a couple of macro codes. I wonder whether you could help me out with then.

Code snippet 1:
A number with the following make-up (##-###-##-##) is to be selected in cell (15,1) of the currently selected table and copied into the clipboard.

Code snippet 2:
The clipboard is to be emptied and pasted into the currently selected table ...
in cell (16,2) after the 28th character.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
0
Comment
Question by:AndreasHermle
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 8

Expert Comment

by:ragnarok89
ID: 34888314
You could just turn on Macro recording, perform the actions you describe, and then turn off Macro recording. A module would auto created containing the code version of the actions you just performed. You could then tweak it to your liking.

Al
0
 

Author Comment

by:AndreasHermle
ID: 34889509
Dear ragnarok89:

Thank you very much for your swift answer. I am aware that I could record it, but - to be honest with you - I would like a professional solution. The macro recorder often records things that in a strict programmer sense is no good.

Regards, Andreas
0
 

Author Comment

by:AndreasHermle
ID: 34895244
Dear all:

only code snippet 2 is relevant. In the meantime I found a solution for code snippet 1.

Here again my requirements for the code snippet:

The clipboard is to be emptied and pasted into the currently selected table ...
in cell (16,2) after the 28th character.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34922107
Can you give me an example?

Sid
0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 1400 total points
ID: 34922132
If I understood your query then this is what you need?

Sub Sample()
    Sheets("Sheet1").Cells(16, 2).Value = Mid(Sheets("Sheet1").Cells(16, 2).Value, 1, 28) & _
                                          Format(Sheets("Sheet1").Cells(15, 1), "##-###-##-##") & _
                                          Mid(Sheets("Sheet1").Cells(16, 2).Value, 17)
End Sub

Open in new window


Sid
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34922136
Please replace "Sheet1" with the respective Sheet Name.

Sid
0
 
LVL 43

Assisted Solution

by:Saqib Husain, Syed
Saqib Husain, Syed earned 600 total points
ID: 34922696
Commands for accessing the clipboard can be found here

http://www.cpearson.com/excel/Clipboard.aspx

Saqib
0
 

Author Comment

by:AndreasHermle
ID: 34932304
Hi Sid,  

thank you very much for your quick support.  I guess there must be some understanding here. My question refers to a Word problem. You are referring to Excel in your post.
But thank you anyway for the  time taken.

Regards,  Andreas
0
 

Author Comment

by:AndreasHermle
ID: 34932313
Hi Sagib:

thank  you very much for your swift help. This link is a valuable resource, thank you. But, as a matter of  fact, my question is a word problem not an Excel problem.

Thank you.

Regards, Andreas
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 34932492
You can make it work in Word by adding a reference to microsoft forms.

To do that, in VBA, go to

tools > references > browse

and select

c:\windows\system32\FM20.DLL

and make sure that microsoft forms 2.0 is in the list and checked.

Saqib
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34932549
Andreas: My apologies for not checking that but then again the logic remains the same in word table as well.

Directly assign the value from one cell of the table to the another. You don't need a clipboard for it.

Sid
0
 

Author Closing Comment

by:AndreasHermle
ID: 34939097
Hi,

thank you very much to both of you for your professional. Regards, Andreas
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
Currently, there is an issue with being able to copy values from an external application to a dropdown list in Project Web Access (PWA).  The standard copy and paste methods don't seem to work properly. Here is a way to accomplish this task to s…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

850 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