Auto copy when a cell is clicked?

L

Legacy 237453

Guest
Hi

I have the below code... I want to make it easyier for a user to be able to copy the values in each cell rather than highlight, right click then copy...

Is there just a way that they can click the cell and it will automatically be copyied?

Thanks Alot
Craig

Code:
Private Sub worksheet_Selectionchange(ByVal Target As Range)
Set Target = Range("F4")
Range("F10").Value = "ls -lrt *" & Target.Value & "*"
Range("F12").Value = "more X" & Target.Value & ".err"
Range("F17").Value = "ls -lrt *" & Target.Value & "*"
Range("F18").Value = "Now you will see a file called perl s_" & Target.Value & ".pl to launch it copy and paste the below command"
Range("F19").Value = "perl s_" & Target.Value & ".pl"
Range("F22").Value = "ls -lrt *" & Target.Value & "*"
Range("F23").Value = "You should have the result….. *" & Target.Value & "* not found"
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
L

Legacy 237453

Guest
Hi..... Quick update...

Ive added Target.Copy to the bottom and it seems to paste. Problem is that it only paste's the value in cell F4

I need it to copy only when i clcik in cells F10, F12, F17, F18, F19, F22, F23

Please can somebody help :)

Thanks in advance!
Craig
 
L

Legacy 237453

Guest
Somebody pleeeeeeeease help me... Im a desperate man haha
 

sagyer

New Member
Joined
Feb 5, 2013
Messages
21
Hi..... Quick update...

Ive added Target.Copy to the bottom and it seems to paste. Problem is that it only paste's the value in cell F4

I need it to copy only when i clcik in cells F10, F12, F17, F18, F19, F22, F23

Please can somebody help :)

Thanks in advance!
Craig

Add this piece of code to the SelectionChange Event in the end :
Code:
Select Case ActiveCell.Address    
    Case "$F$10"
        ActiveCell.Copy
    Case "$F$12"
        ActiveCell.Copy
    Case "$F$17"
        ActiveCell.Copy
    Case "$F$18"
        ActiveCell.Copy
    Case "$F$19"
        ActiveCell.Copy
    Case "$F$22"
        ActiveCell.Copy
    Case "$F$23"
        ActiveCell.Copy
End Select

It will copy only the above cells when clicked.

Regards,

Sagar Yerunkar
 
L

Legacy 237453

Guest

ADVERTISEMENT

Add this piece of code to the SelectionChange Event in the end :
Code:
Select Case ActiveCell.Address    
    Case "$F$10"
        ActiveCell.Copy
    Case "$F$12"
        ActiveCell.Copy
    Case "$F$17"
        ActiveCell.Copy
    Case "$F$18"
        ActiveCell.Copy
    Case "$F$19"
        ActiveCell.Copy
    Case "$F$22"
        ActiveCell.Copy
    Case "$F$23"
        ActiveCell.Copy
End Select

It will copy only the above cells when clicked.

Regards,

Sagar Yerunkar

Hi thanks for your reply!!! I cant work out where i should be adding this? can you add it to my orinianal code please :)

Thank you sooo much!
 

sagyer

New Member
Joined
Feb 5, 2013
Messages
21
Code:
Private Sub worksheet_Selectionchange(ByVal Target As Range)
Set Target = Range("F4")
Range("F10").Value = "ls -lrt *" & Target.Value & "*"
Range("F12").Value = "more X" & Target.Value & ".err"
Range("F17").Value = "ls -lrt *" & Target.Value & "*"
Range("F18").Value = "Now you will see a file called perl s_" & Target.Value & ".pl to launch it copy and paste the below command"
Range("F19").Value = "perl s_" & Target.Value & ".pl"
Range("F22").Value = "ls -lrt *" & Target.Value & "*"
Range("F23").Value = "You should have the result….. *" & Target.Value & "* not found"




Select Case ActiveCell.Address
    Case "$F$10"
        ActiveCell.Copy
    Case "$F$12"
        ActiveCell.Copy
    Case "$F$17"
        ActiveCell.Copy
    Case "$F$18"
        ActiveCell.Copy
    Case "$F$19"
        ActiveCell.Copy
    Case "$F$22"
        ActiveCell.Copy
    Case "$F$23"
        ActiveCell.Copy
End Select


End Sub

There you go!

Regards,

Sagar Yerunkar
 
L

Legacy 237453

Guest
Thank you sooo much! once again this fourm comes to the rescue :)
 

Watch MrExcel Video

Forum statistics

Threads
1,130,346
Messages
5,641,598
Members
417,225
Latest member
LukiiMaxim96

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top