Original: Use VBA to merge and copy the mouse-selected cells to the clipboard in the specified format
I. Mainly implement the following functions:
1. After selecting a cell (continuous cell or discontinuous) with the mouse, merge the files in the required format, such as "document number: + selected content +", "+ selected content ".
2. The merged content is directly copied to the clipboard.
Ii. Sample Code:
Sub TESTA () set a = new dataobject 'stores the range ("B2") of the cells in the merged result ") = "" 'start to merge the content of the selected cell for each C in selectionrange ("B2 "). value = range ("B2 "). value & C. value & "," Next "copies the summary result to the clipboard range (" B2 ") =" document number: "& range (" B2 ") range (" B2 "). selectrange ("B2") = left (range ("B2"), Len (range ("B2")-1) range ("B2 ") = range ("B2 ")&". "'Range (" B2 "). Select 'selection. copy' ------------- A. settext range (" B2 ") A. putinclipboardend sub
Iii. Example files and operation videos:
Join the QQ Group to download sample files and demo videos for group sharing:
QQ: 303625469
: Excel_cortana