Copy and paste data upon click [Closed]

Report
Posts
3
Registration date
Tuesday February 13, 2018
Status
Member
Last seen
February 15, 2018
-
 Blocked Profile -
I have a set of data on A2 to A10. When I hit cell A2 which contain the word "January", the data will be copied into B2.

If I hit cell A3 which contain the word "March", then the data will be copied into B2

If anyone have suggestion for this???

2 replies


Please understand we are volunteers. We help when you are stuck.

In this case, you need to understand the IF statement.

The syntax for IF is:
=IF(logic_test,True,False)


So, in cell B2, place your IF code. If the logic test is true, then the True will be presented.

Let us know if you get stuck on this homework, which is what this sounds like.
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2942 users have said thank you to us this month

Posts
3
Registration date
Tuesday February 13, 2018
Status
Member
Last seen
February 15, 2018

Actually I used below code error

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean))
If Intersect(Target, Range("A2:A10")) Is Nothing Then
Exit Sub
Target.Copy Destination:= range("B2")
End Sub
A cleaner way would be 1 liner:

 If Intersect(Target, Range("A2:A10")) Is Nothing Then Exit Sub 


Your code does not qualify the entry, so any value in any of those will FIRE your routine. You specifically asked to qualify when a value is there, and your entry does not do that! I am confused!


Have fun.
Posts
3
Registration date
Tuesday February 13, 2018
Status
Member
Last seen
February 15, 2018

Sorry its not working....
Blocked Profile
What isn't working?

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!