XLA routines: EE_Copy
EE_Copy is one of the most used EE sub routines. Specify the source, and the top left of the target, and EE_Copy will copy the data over. Optionals to debug (go to each range), and transpose, or copy formatting too.
Sub EE_Copy(rngSource As range, rngTopLeftTarget As range, Optional blnCopyValues As Boolean = True, Optional blnCopyFormatting As Boolean = True, Optional blnTranspose As Boolean = False, Optional blnDebug As Boolean = False) 'Function EE_Copy() '- takes source range '- target range (top left cell only) ' 'Optional: '- boolean copyValues '- boolean copyFormatting '- boolean Transpose '- boolean Debug ' '- default to copy values and formatting, no transpose or debug ' '- if debug set to true, 3 messageboxes are displayed: ' - 1 showing the source range ' - 1 showing the target range as it is now ' - 1 showing the target range after it has been copied over ' - source and target range cell interiors are coloured green 'http://excelexperts.com/xla-routines-eeCopy for updates on this sub routine If blnDebug Then Application.GoTo rngSource MsgBox "Source range", vbInformation End If rngSource.Copy If blnDebug Then Application.GoTo rngTopLeftTarget MsgBox "Target range before paste.", vbInformation End If If blnCopyValues Then rngTopLeftTarget.PasteSpecial Paste:=xlPasteValues, Transpose:=blnTranspose Else rngTopLeftTarget.PasteSpecial Paste:=xlPasteFormulas, Transpose:=blnTranspose End If If blnCopyFormatting Then rngTopLeftTarget.PasteSpecial Paste:=xlPasteFormats, Transpose:=blnTranspose End If If blnDebug Then Application.GoTo rngTopLeftTarget MsgBox "Target range after paste.", vbInformation End If Application.CutCopyMode = False End Sub
»
- Nick's blog
- Login or register to post comments
- 3083 reads
Recent comments
5 years 41 weeks ago
6 years 27 weeks ago
6 years 39 weeks ago
6 years 42 weeks ago
6 years 43 weeks ago
6 years 48 weeks ago
7 years 4 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago