Solved

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

Posted on 2011-02-14
14
272 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
[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
  • 5
  • 4
  • 2
  • +1
14 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
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!

 
LVL 30

Expert Comment

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

Sid
0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 350 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 150 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

749 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