Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi. I've got a macro the copies the value in whatever cell (varies) when it is double clicked to another cell on another sheet (static, E2). I recorded a macro without selecting the cell first (just recorded the copy and paste to the specific cell). Afterwords, I made a BeforeDoubleClick worksheet module. If I run this code as a regular Sub macro, it works just fine. But when I try to run it as a worksheet BeforeDoubleClick macro, I get a run-time error that says, 'Run-time error 1004: Select method of Range class failed.' The code is below, and it fails at the Range("E2").Select line. I tried Range("E2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False, but that also failed. I Googled this and found that others have done this successfully, so what is going wrong here with mine? Thanks for any insights. Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Application.CutCopyMode = False Selection.Copy Sheets("InvestigatorPro").Select Range("E2").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi,
if you want to copy only the value and not the format Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Sheets("InvestigatorPro").Range("E2") = Target.Value End Sub isabelle Le 2015-05-11 21:00, Phrank a écrit : Hi. I've got a macro the copies the value in whatever cell (varies) when it is double clicked to another cell on another sheet (static, E2). I recorded a macro without selecting the cell first (just recorded the copy and paste to the specific cell). Afterwords, I made a BeforeDoubleClick worksheet module. If I run this code as a regular Sub macro, it works just fine. But when I try to run it as a worksheet BeforeDoubleClick macro, I get a run-time error that says, 'Run-time error 1004: Select method of Range class failed.' The code is below, and it fails at the Range("E2").Select line. I tried Range("E2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False, but that also failed. I Googled this and found that others have done this successfully, so what is going wrong here with mine? Thanks for any insights. Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Application.CutCopyMode = False Selection.Copy Sheets("InvestigatorPro").Select Range("E2").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro to copy data and paste to a new sheet in next available cell | Excel Programming | |||
Help to code Macro to Copy fron one sheet and paste in other sheet | Excel Programming | |||
Active Cell Copy And Paste Sheet to Sheet | New Users to Excel | |||
Copy and Paste macro needs to paste to a changing cell reference | Excel Programming | |||
Macro help - copy row, clear, and paste on different sheet | Excel Programming |