Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
i have two worksheets. one store inventory and one sales reciept. all
products have item number in first column. when i sell an item, i want to be able to double click that cell and auto copy other data in that row to the sales reciept worksheet. thanks |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I think this will do the trick for you. Put this in the sheet's code section
for the sheet where you want to do the double-click trick. Hopefully code is commented well enough so you can see what you need to change for your real-world setup. Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _ Cancel As Boolean) 'How to insert code into worksheets: 'http://www.jlathamsite.com/Teach/WorksheetCode.htm 'name of Sales Record Sheet Const Destination = "Sheet2" '<- Change 'Column ID where to paste on the ' Sales Record Sheet to receive the copy Const DestColumn = "A" '<- change? 'Column ID to be double-clicked to cause move Const DblClkColumn = "A" '<- Change? Dim DestRange As Range If Target.Cells.Count 1 Then 'not sure how, but if... Exit Sub End If If Target.Column < Range(DblClkColumn & Target.Row).Column Then Exit Sub End If 'copy from column A to last used cell in row Range("A" & Target.Row & ":" & _ Range("IV" & Target.Row).End(xlToLeft).Address).Copy 'determine where to paste on destination sheet Set DestRange = Worksheets(Destination).Range(DestColumn & _ "65536").End(xlUp).Offset(1, 0) 'paste all - could use xlPasteValues here instead DestRange.PasteSpecial xlPasteAll Cancel = True ' cancel actual double-click action Application.CutCopyMode = False End Sub "YaYa" wrote: i have two worksheets. one store inventory and one sales reciept. all products have item number in first column. when i sell an item, i want to be able to double click that cell and auto copy other data in that row to the sales reciept worksheet. thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro | Excel Discussion (Misc queries) | |||
how to copy a cell with formula from sheet 1 (data is all vertical) into sheet 2 | Excel Worksheet Functions | |||
if and then formula | Excel Worksheet Functions | |||
copy data from various sheets into one sheet | Excel Worksheet Functions | |||
Input cell reference is not valid (One Variable Data Table) | Excel Worksheet Functions |