Configuration: Windows 2003 Internet Explorer 7.0
Will This Help ? (below...)
'Macro to copy the text in several cells on several worksheets to the clipboard for pasting. Public Sub CopyIt() 'I assume you will loop through several worksheets in a workbook so I created a sheet object. Dim Sheet As Excel.Worksheet 'I made a variable to hold the text from the cells. Dim Txt As String 'I created a data object to use with the clipboard. 'You must have 'Microsoft Forms 2.0 Object Library' checked in "Tools" - "References" 'in order to use the 'DataObject' type. Dim MyData As New DataObject 'Clear the text. Txt = "" 'Loop through each of the sheets in the workbook... 'If you only want one worksheet then you don't need the loop or the sheet variable, ' instead you can use 'ActiveSheet' or name the sheet directly. For Each Sheet In ActiveWorkbook.Sheets 'Add each cell in the sheet to the text variable using the cells function. 'I just put numbers in this one the numbers you have will depend on where the data is 'in your form. ( the vbtab tells it to move over by one column before the next data is added. ) Txt = Txt & Sheet.Cells(4, 5) & vbTab Txt = Txt & Sheet.Cells(6, 5) & vbTab Txt = Txt & Sheet.Cells(8, 5) & vbTab Txt = Txt & Sheet.Cells(4, 7) & vbTab Txt = Txt & Sheet.Cells(6, 7) & vbTab Txt = Txt & Sheet.Cells(8, 7) & vbTab 'You could put the vbCrLf below here instead of vbTab. 'This tells it to add a return and line feed so the data from the next sheet 'will go to the next line instead of one big long line. Txt = Txt & vbCrLf 'Finish the loop. Next Sheet 'This uses the Data Object to put the collected text on the clipboard. MyData.SetText Txt MyData.PutInClipboard 'You are now ready to paste ! End Sub |
Résultats pour Macro Help In Excel COPY PASTING
Résultats pour Macro Help In Excel COPY PASTING
Résultats pour Macro Help In Excel COPY PASTING
Résultats pour Macro Help In Excel COPY PASTING
Résultats pour Macro Help In Excel COPY PASTING