Copy cell to another cell using Macro
How about getting rid of the rectangle(s) completely and using the
worksheet's _BeforeDoubleClick event to do the work when you double-click a
cell in column A? Would that work for you? Here's code to do that. To put
the code into the proper place, right-click on the worksheet's name tab and
choose [View Code] from the popup list. copy and paste the code below into
the code module area that appears. From then on, when you double-click in
column A, whatever is in column be on the same row will be echoed into column
C on that row.
I'll 'warn' about this: sometimes when you click in the cell and try to
double click, the system may miss the double click, interpreting it as 2
single clicks. That happens to me sometimes. If the operation doesn't work
first try, try again. When I set something up like this, I try to remember
to first click in the cell and THEN, after a very short pause, do the actual
double-click.
Private Sub Worksheet_BeforeDoubleClick(ByVal _
Target As Range, Cancel As Boolean)
If Target.Column = 1 Then
Target.Offset(0, 2) = Target.Offset(0, 1)
End If
End Sub
"Robert B." wrote:
I am trying to create a macro (attached to a transparent rectangle in cell A)
that will copy contents of cell B to Cell C and paste as a value. Problem I
have now is the transparent rectangle is duplicated each time it is activated
in cell A (macro does copy correctly to cell C) and I have to click on the
left side of cell A and slide over to the right side to activate transparent
rectangle (attached to macro) - any way to activate macro without clicking on
left side and sliding over the right.
See Example of Macro I have so far. Any help will be greatly appreciated.
Sub Macro4()
'
' Macro4 Macro
' Macro recorded 10/15/2007 by Robert
'
'
Application.ScreenUpdating = False
ActiveCell.FormulaR1C1 = "R"
ActiveCell.Offset(0, 1).Select
Selection.Copy
ActiveCell.Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Application.OnKey "{ENTER}"
Range("o7").Select
ActiveCell.Select
End Sub
Robert B.
|