Macro error when copying pasting from clipboard

danhendo888

Board Regular
Joined
Jul 15, 2019
Messages
167
Office Version
  1. 365
Platform
  1. Windows
Trying to copy a column and paste using the clipboard on the Home ribbon.
When I do this it usually converts the text values to numbers (for numbers that I copied and pasted externally)

Run-time error: 1004
Paste method of worksheet class failed

Sheets("Sheet2").Select
Range("K2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Application.CutCopyMode = False
ActiveSheet.Paste
Application.CommandBars("Office Clipboard").Visible = False
ActiveCell.Offset(-1, 0).Range("Table1[[#Headers],[GL Account]]").Select
 

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.
also
Code:
Application.CutCopyMode = False
means you are exiting cut/copy mode so you should put it at the end of copy pasting
 
Upvote 0
Hmm, it's not working for me. Getting a 438 error.

When I extract data from a software and paste it into my sheet, there are numbers that are stored as text and that I need to convert to numbers.
I usually do this by selecting the range, opening the clipboard, copying to clipboard, hitting Paste All. This will convert the numbers stored as text, to numbers.

So that's what I recorded in my macro. Not sure if there is a better way to do it.
File link FYI

https://1drv.ms/x/s!AvjBsEPEq12ngS9ITAe84IHxcI2Q?e=EMRSJg
 
Upvote 0
Try...

Code:
With Sheets("Sheet2").ListObjects("Table1").DataBodyRange
  .Value = .Value
End With
 
Upvote 0
Code:
Sub ABC()
 With Sheets("Sheet2").ListObjects("Table1").ListColumns(11).Range
   .Value = .Value
 End With
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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