LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Repeat cell content

Oops,
I wrote row = target.column. This is of course an error. Should be
row = target.row

Ko Vijn


Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
'target is the cellobject that was rightclicked
Cancel = True ' prevents the usual contextmenu to show
col = Target.Column
row = target.column
if col=4 then
lastval= Cells(row-1, col) 'value in the row above
Cells(Target.Row, col) = lastval
endif
End Sub
In your example: a rightclick on col D row 3 (now empty) will copy ABC MAN
in that cell

You may vary on this theme by inserting a For/Next, looking for a cell

which
is not empty, etcetera

Alternatively, if you do not want to use this RightClick procedure, try
something like:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target = "*" Then
col = Target.Column
row = target.column
if col=4 then
lastval= Cells(row-1, col) 'value in the row above
Cells(Target.Row, col) = lastval
endif
endif
On Error GoTo 0
End Sub

In this example, if you type * in col D row 3 it will copy the value of

the
cell above, at least if it happens in colums 4 (D)
Of course you may change * for any other printable character and/or use
other conditions.

HTH, Ko




 
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
how do i set up if cell content repeat, warn given lahiripranab Excel Worksheet Functions 2 February 21st 09 05:50 PM
copy comment content to cell content as data not as comment Lilach Excel Discussion (Misc queries) 2 June 21st 07 12:28 PM
how do i find cells that repeat the same content? cdoyle Excel Worksheet Functions 1 September 22nd 05 03:47 PM
Title Cut Off if Rows to Repeat & Columns to Repeat are Both Selec unibaby Excel Discussion (Misc queries) 2 August 24th 05 04:29 PM
HELP: How to Repeat Cell Content into a Second Worksheet ? Vince Excel Worksheet Functions 2 August 12th 05 07:19 PM


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

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

About Us

"It's about Microsoft Excel"