ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to copy formula and paste into another (https://www.excelbanter.com/excel-programming/429788-macro-copy-formula-paste-into-another.html)

usmc-r70

Macro to copy formula and paste into another
 
I found and successfully loaded the following code, but I must use the ENTER
key for it to be fully posted.

Any idea?

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
n = Target.Row
With Target
..Value = Excel.Range("D" & n).Formula
End With
SendKeys "{ENTER}", True
End Sub




Gary''s Student

Macro to copy formula and paste into another
 
You need the SendKeys to get you out of cell edit. You can avoid this by
setting Cancel=True

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
End Sub
--
Gary''s Student - gsnu200856


"usmc-r70" wrote:

I found and successfully loaded the following code, but I must use the ENTER
key for it to be fully posted.

Any idea?

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
SendKeys "{ENTER}", True
End Sub




Jacob Skaria

Macro to copy formula and paste into another
 
n = Target.Row
With Target
..Value = Excel.Range("D" & n).Formula
End With
Cancel = True

If this post helps click Yes
---------------
Jacob Skaria


"usmc-r70" wrote:

I found and successfully loaded the following code, but I must use the ENTER
key for it to be fully posted.

Any idea?

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
SendKeys "{ENTER}", True
End Sub




r

Macro to copy formula and paste into another
 
Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
Dim n As Long
n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
Target.Offset(1).Select
End Sub

regards
r

Il mio ultimo lavoro ...
http://excelvba.altervista.org/blog/...ternative.html


"usmc-r70" wrote:

I found and successfully loaded the following code, but I must use the ENTER
key for it to be fully posted.

Any idea?

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
SendKeys "{ENTER}", True
End Sub




usmc-r70

Macro to copy formula and paste into another
 
That solution worked, thanks!

"Gary''s Student" wrote:

You need the SendKeys to get you out of cell edit. You can avoid this by
setting Cancel=True

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
End Sub
--
Gary''s Student - gsnu200856


"usmc-r70" wrote:

I found and successfully loaded the following code, but I must use the ENTER
key for it to be fully posted.

Any idea?

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
SendKeys "{ENTER}", True
End Sub




usmc-r70

Macro to copy formula and paste into another
 
That worked as well! Amazing how many different approaches can result in the
same outcome! Thanks to you all from USMC in Iraq.

"Jacob Skaria" wrote:

n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
Cancel = True

If this post helps click Yes
---------------
Jacob Skaria


"usmc-r70" wrote:

I found and successfully loaded the following code, but I must use the ENTER
key for it to be fully posted.

Any idea?

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
SendKeys "{ENTER}", True
End Sub




usmc-r70

Macro to copy formula and paste into another
 
And to 'r', thanks for your quick response and effective code.

"r" wrote:

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
Dim n As Long
n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
Target.Offset(1).Select
End Sub

regards
r

Il mio ultimo lavoro ...
http://excelvba.altervista.org/blog/...ternative.html


"usmc-r70" wrote:

I found and successfully loaded the following code, but I must use the ENTER
key for it to be fully posted.

Any idea?

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
SendKeys "{ENTER}", True
End Sub




usmc-r70

Macro to copy formula and paste into another
 
Gary, If I wanted to limit where this code works, (i.e. Column D or a range
of cells) what would the code look like?

"Gary''s Student" wrote:

You need the SendKeys to get you out of cell edit. You can avoid this by
setting Cancel=True

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
End Sub
--
Gary''s Student - gsnu200856


"usmc-r70" wrote:

I found and successfully loaded the following code, but I must use the ENTER
key for it to be fully posted.

Any idea?

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
SendKeys "{ENTER}", True
End Sub




usmc-r70

Macro to copy formula and paste into another
 
Correction, limit code response to any column other than D.

"Gary''s Student" wrote:

You need the SendKeys to get you out of cell edit. You can avoid this by
setting Cancel=True

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
End Sub
--
Gary''s Student - gsnu200856


"usmc-r70" wrote:

I found and successfully loaded the following code, but I must use the ENTER
key for it to be fully posted.

Any idea?

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As
Boolean)
n = Target.Row
With Target
.Value = Excel.Range("D" & n).Formula
End With
SendKeys "{ENTER}", True
End Sub





All times are GMT +1. The time now is 07:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com