PDA

View Full Version : select and enter



aoc
09-05-2008, 11:40 PM
hi,

I will select one cell or several cells then press enter. then the datas in the cells will be copied to the sheet1 in order in the same workbook. how can I do ?

mdmackillop
09-06-2008, 01:30 AM
I don't understand this

will be copied to the sheet1 in order

but try

In sheet module
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.OnKey "~", "CrazyEnter"
End Sub

In Standard module
Sub CrazyEnter()
Selection.Copy Sheets(2).Range(Selection(1).Address)
Application.OnKey "~"
End Sub

aoc
09-08-2008, 04:06 AM
hi,

I attached the file that I wrote the code. but it did not work.

you will select the numbers in sheet2 and press enter. when you enter, the numbers will be copied to a1 a2 a3 a4 in sheet1

regards

Bob Phillips
09-08-2008, 05:21 AM
You need to initialise the enter key



Private Sub Workbook_Open()
Application.OnKey "~", "CrazyEnter"
End Sub


This is workbook event code.
To input this code, right click on the Excel icon on the worksheet
(or next to the File menu if you maximise your workbooks),
select View Code from the menu, and paste the code

aoc
09-08-2008, 05:46 AM
dear all,

I attached the file that I wrote the code. but it did not work.

you will select the numbers in sheet2 and press enter. when you enter, the numbers will be copied to a1 a2 a3 a4 in sheet1.

can you please help.

aoc
09-08-2008, 05:57 AM
hi,


I attached the file to the below message that I wrote the code. but it did not work.

you will select the numbers in sheet2 and press enter. when you enter, the numbers will be copied to a1 a2 a3 a4 in sheet1

regards

Bob Phillips
09-08-2008, 06:28 AM
Did you read my response?

aoc
09-08-2008, 07:12 PM
Did you read my response?
hi,

I tried but it did not work, can you write on the file on message Yesterday, 03:46 PM and send me

Bob Phillips
09-09-2008, 02:18 AM
Here it is

aoc
09-09-2008, 03:58 AM
hi,

thanks. it works but to be more useful can it be copied to a1 if empty then a2 then a3 then a4 ..... for every pressed enter it will be copied to cell a(x+1). x is the last full cell.

mdmackillop
09-09-2008, 04:50 AM
Please try to provide all relevant information in your initial query.
Can your selection extend to more than one column?

aoc
09-09-2008, 06:54 AM
hi,

I will select from one column.
for example b1 b3 b7..... I will select them seperately with ctrl and press enter. then they will be copied to other sheet. one by one.

as

a1
a2
a3
.
.
.

if it is b1 b2 b3 I will not use ctrl to select I will drag mouse