Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
r r is offline
external usenet poster
 
Posts: 125
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula/ Macro that will copy and paste Randy Excel Worksheet Functions 1 August 12th 08 03:58 PM
I need formula help or create a macro to copy and paste value only Rebecca Excel Discussion (Misc queries) 4 April 8th 06 01:18 PM
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM
Macro to Copy/Paste then Paste to Next Line tomkarakowski Excel Programming 1 May 28th 04 01:19 AM


All times are GMT +1. The time now is 01:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"