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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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
 
Upvote 0
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
 
Upvote 0
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!
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

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
Back
Top