ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy selected cells (https://www.excelbanter.com/excel-programming/385970-copy-selected-cells.html)

[email protected]

Copy selected cells
 
I have what I think is an easy one.

I have a sheet that has about 500 rows. In Column A everything is
blank. In Column B maybe blank, but there are some notes in some of
the cells. What I'm trying to do is IF, there are notes in cell B10
for example I would like the user to beable to click that cell, B10
and have the contents copied from B10 to A10.

The macro would only fire any cell in column B....make sense? Thanks
for your help!!


Gary''s Student

Copy selected cells
 
How about double-click:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Intersect(Range("B:B"), Target) Is Nothing Then
Exit Sub
End If
If IsEmpty(Target) Then
Exit Sub
End If
Target.Copy Target.Offset(0, -1)
Cancel = True
End Sub

this goes in worksheet code, not a standard module
--
Gary''s Student
gsnu200711


" wrote:

I have what I think is an easy one.

I have a sheet that has about 500 rows. In Column A everything is
blank. In Column B maybe blank, but there are some notes in some of
the cells. What I'm trying to do is IF, there are notes in cell B10
for example I would like the user to beable to click that cell, B10
and have the contents copied from B10 to A10.

The macro would only fire any cell in column B....make sense? Thanks
for your help!!



Tom Ogilvy

Copy selected cells
 
Why not do this when the user double clicks:

right click on the sheet tab and select View code. Put in code like this:

Private Sub Worksheet_BeforeDoubleClick(ByVal _
Target As Range, Cancel As Boolean)
If target.count = 1 then
if Target.column = 2 then
if not isempty(Target) then
Target.offset(0,-1).value = target.value
Cancel = True
end if
end if
end if
End Sub

by note I assume you mean text in the cell; not a cell comment.

--
Regards,
Tom Ogilvy

" wrote:

I have what I think is an easy one.

I have a sheet that has about 500 rows. In Column A everything is
blank. In Column B maybe blank, but there are some notes in some of
the cells. What I'm trying to do is IF, there are notes in cell B10
for example I would like the user to beable to click that cell, B10
and have the contents copied from B10 to A10.

The macro would only fire any cell in column B....make sense? Thanks
for your help!!



[email protected]

Copy selected cells
 
On Mar 23, 9:24 am, Gary''s Student
wrote:
How about double-click:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Intersect(Range("B:B"), Target) Is Nothing Then
Exit Sub
End If
If IsEmpty(Target) Then
Exit Sub
End If
Target.Copy Target.Offset(0, -1)
Cancel = True
End Sub

this goes in worksheet code, not a standard module
--
Gary''s Student
gsnu200711



" wrote:
I have what I think is an easy one.


I have a sheet that has about 500 rows. In Column A everything is
blank. In Column B maybe blank, but there are some notes in some of
the cells. What I'm trying to do is IF, there are notes in cell B10
for example I would like the user to beable to click that cell, B10
and have the contents copied from B10 to A10.


The macro would only fire any cell in column B....make sense? Thanks
for your help!!- Hide quoted text -


- Show quoted text -


Perfect...thanks...I like the double click option....Thanks..



All times are GMT +1. The time now is 11:14 PM.

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