Selection.Copy not working

overbet

Board Regular
Joined
Jul 9, 2010
Messages
63
Office Version
  1. 2010
Does anyone have any idea why I am not able to get this macro to copy cell data?
Here is the last part of the code:

Code:
  SendKeys "~"
'presses enter to move down one cell
  SendKeys "^{k}"
 'runs macro shortcut
  
  Call Copy_Location
End Sub
Sub Copy_Location()
'moves right 3 cells
    Application.SendKeys "{TAB}"
    Application.SendKeys "{TAB}"
    Application.SendKeys "{TAB}"
    Selection.Copy
    'SendKeys "^{c}"
End Sub

I am not very good at VBA, but this is what I am trying to do here. I put this piece of code at the end of a macro I am using regularly to cut a couple manual steps out of my work. The code needs to go down one cell (SendKeys "~"), the it runs a another macro shortcut (SendKeys "^{k}"), then it calls the rest that moves the selected cell 3 cells to the right, then finally it is supposed to copy that cells data so I can manually paste it elsewhere. This works for all the steps except the final step of copying the cell data. I tired Selection.copy and I tried SendKeys "^{c}". Neither work for me.

Like I said I am not good with vba so I am sure this a convoluted method and there is a better way. This works for every step except the last step. If I comment out the last step, the copy, it goes right to the cell I need the data from. If I leave the copy step in, it doesnt get past the first step of pressing the enter key. Thanks for any suggestions.
 
This is what I ended up with that worked how I needed it.

Code:
ActiveCell.Offset(0, 4).Copy
 Selection(2).Select
 Selection(0, 4).Copy
 
Last edited:
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,223,889
Messages
6,175,226
Members
452,620
Latest member
dsubash

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