vba copy/paste

zrx1200

Well-known Member
Joined
Apr 14, 2010
Messages
622
Office Version
  1. 2019
Platform
  1. Windows
excel 2010, code fails snippet Public Sub runcopy()
Application.Goto Reference:="Current_run"
Selection.Copy
Range("o1").Select
ActiveSheet.Paste
Application.CutCopyMode = False the code highlights the paste destination but no vales?? no errors
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
There's no copy statement, after the Goto, you don't copy, so there's nothing to paste or so I think
 
Upvote 0
excel 2010, code fails snippet Public Sub runcopy()
Application.Goto Reference:="Current_run"
Selection.Copy
Range("o1").Select
ActiveSheet.Paste
Application.CutCopyMode = False the code highlights the paste destination but no vales?? no errors
The above code worked fine in my tests. Once you get the problem figured out... just so you know, there is no need to select anything in order to copy it somewhere else. The following single line of code does what your above code does, but without selecting something first and... you do not have to deal with the "marching ants".

Code:
Range("Current_run").Copy Range("O1")
 
Upvote 0
Hi,
I can find nothing wrong with your code, assuming your live code doen't have the text you posted at the end of its last line. The most obvious explanation would be that the named range "Current_Run" that
your copying is empty, so there is nothing to paste.

Check that out first - with any other possibilities I can think of the code should complain. I imagine that youve recorded some/all of the code which is why its "over-elaborate".
 
Last edited:
Upvote 0
The above code worked fine in my tests. Once you get the problem figured out... just so you know, there is no need to select anything in order to copy it somewhere else. The following single line of code does what your above code does, but without selecting something first and... you do not have to deal with the "marching ants".

Code:
Range("Current_run").Copy Range("O1")
While this does run under F8, it will not copy under F5. I use a button on form linked to macro. I noticed that my code will loop through the Private Sub Worksheet_SelectionChange(ByVal Target As Range) as I run other subs in standard module because sheet see a change, but I fail to see why this would affect the copy? I think something is affecting it but what if it works in F8 mode?
 
Upvote 0
Hi,
I can find nothing wrong with your code, assuming your live code doen't have the text you posted at the end of its last line. The most obvious explanation would be that the named range "Current_Run" that
your copying is empty, so there is nothing to paste.

Check that out first - with any other possibilities I can think of the code should complain. I imagine that youve recorded some/all of the code which is why its "over-elaborate".

range has data, although full range is not occupied (could this be the issue).
 
Upvote 0
Hi,
I can find nothing wrong with your code, assuming your live code doen't have the text you posted at the end of its last line. The most obvious explanation would be that the named range "Current_Run" that
your copying is empty, so there is nothing to paste.

Check that out first - with any other possibilities I can think of the code should complain. I imagine that youve recorded some/all of the code which is why its "over-elaborate".
So, upon further study I found that my code had clear statement in it which I put in the wrong spot in the sub allowing the range to be "empty" just like you had mentioned. Sure took awhile but somehow the light got turned on and I remembered clearing the range in one of the subs! Solved.
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,255
Members
448,879
Latest member
oksanana

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