View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default How to read previous copy selection address

Adax,

VBA does not have a method to address non-string values of the clipboard.
But you can set up an event to capture the copy or cut - within a workbook,
but not between workbooks - and have that value available. Copy this
(somewhat tested, but not fully tested) code into the ThisWorkbook
codemodule:

Option Explicit
Dim myAdd1 As String
Dim myAdd2 As String
Dim CCAdd As String
Dim WasNotCopy As Boolean

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)

If myAdd1 < "" Then
myAdd2 = myAdd1
myAdd1 = Target.Address(True, True, xlA1, True)
Else
myAdd1 = Target.Address(True, True, xlA1, True)
myAdd2 = myAdd1
End If

If (Application.CutCopyMode = xlCopy Or _
Application.CutCopyMode = xlCut) And WasNotCopy Then
MsgBox "Clipboard has " & CCAdd
End If
If (Application.CutCopyMode = xlCopy Or _
Application.CutCopyMode = xlCut) And Not WasNotCopy Then
CCAdd = myAdd2
MsgBox "Clipboard has " & CCAdd
WasNotCopy = True
End If
If Application.CutCopyMode = False Then WasNotCopy = False
End Sub


HTH,
Bernie
MS Excel MVP


"Adax" wrote in message ...
Hallo! I'm looking for solution how to read previous copy selection
address. Is it possible in VBA in excel?
For instance:
1. select A1:B4
2. Ctrl + C
3 select G5
4 How to read this previous copy selection address (A1:B4)?
Thanks for any help, Adax