ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   excel: if selected, copy cell from corresponding row (https://www.excelbanter.com/excel-worksheet-functions/161178-excel-if-selected-copy-cell-corresponding-row.html)

davey-in-the-navy

excel: if selected, copy cell from corresponding row
 
is it possible to make a formula (or macro) so if a cell from column "A" is
selected, then a cell from that same row will be copied to another sheet?
example:
A3 in sheet 1 is selected, D3 from sheet 1 is automaticly copied to wherever
specified in sheet 2
I would like to set it up so only 1 cell in column A can be selected at a
time.

I greatly appreciate any help.

Gary''s Student

excel: if selected, copy cell from corresponding row
 
Assume the source sheet is "Sheet1".
Assume the destination sheet is "Sheet2", the destination cell is B9.

Put the following macro in the "Sheet1" worksheet code area:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim s1 As Worksheet
Dim s2 As Worksheet
Dim r1 As Range, r2 As Range
Set s1 = Sheets("Sheet1")
Set s2 = Sheets("Sheet2")
Set r1 = s1.Range("A:A")
Set r2 = s2.Range("B9")
If Intersect(Target, r1) Is Nothing Then Exit Sub
Target.Offset(0, 3).Copy r2
End Sub

Whenever a cell in column A is selected, the equivalent cell in column D is
copied to the destination cell in the other worksheet.

REMEMBER: the worksheet code area, not a standard module.
--
Gary''s Student - gsnu200748


"davey-in-the-navy" wrote:

is it possible to make a formula (or macro) so if a cell from column "A" is
selected, then a cell from that same row will be copied to another sheet?
example:
A3 in sheet 1 is selected, D3 from sheet 1 is automaticly copied to wherever
specified in sheet 2
I would like to set it up so only 1 cell in column A can be selected at a
time.

I greatly appreciate any help.



All times are GMT +1. The time now is 12:28 AM.

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