Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do i set up if cell content repeat, warn given | Excel Worksheet Functions | |||
copy comment content to cell content as data not as comment | Excel Discussion (Misc queries) | |||
how do i find cells that repeat the same content? | Excel Worksheet Functions | |||
Title Cut Off if Rows to Repeat & Columns to Repeat are Both Selec | Excel Discussion (Misc queries) | |||
HELP: How to Repeat Cell Content into a Second Worksheet ? | Excel Worksheet Functions |