Paste Special as Text

Drivingman

New Member
Joined
Jan 26, 2012
Messages
19
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi All

Hoping you can help a VBA beginner.

I have data that I am copying from EXCEL 16, and pasting into EXCEL 07. Unfortunately no way around this backward paste. Customer still on old version.

I can manually paste the data in, but repetitive as have 5 days of data to paste.
When I use the following macro, it pastes it in as an image and not into the cells directly.
Sub TextBox1_Click()
'
' TextBox1_Click Macro
' Paste into Monday
'
'

With Sheets("Control")
.Range("d8").PasteSpecial xlPasteAll
End With
End Sub

When I have tried the following amended macro it generates an error.
Sub TextBox1_Click()
'
' TextBox1_Click Macro
' Paste into Monday
'
'
With Sheets("Control")
.Range("d8").PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:= _
False
End With
End Sub


The data should be pasted into cells D8:L57 on sheet Control.
Once I have that sorted I then need to amend to paste Tuesday into D61:L110, and so on through to Friday.
On my front sheet I have 5 text boxes which I am hoping to have the 5 macros assigned to.
Hope this all makes sense.

TYIA.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
A couple of comments.

1) Normally to paste something you need to copy something first. I don't see any "copy" statements in your code. What is being copied?
2) You've mentioned that an error was generated. There are all kinds of errors. When excel generates an error, it is important to be very specific about exactly which error and it's error message when posting about it, because that is information that will provide a clue as to what is going on.
 
Upvote 0
Hi rlv01

1 - The data to be pasted is copied from another excel 2016 spreadsheet that is generated from Injixo - our workforce management software. Each day is produced separately and could be named Book1 - 5. Each spreadsheet has a sheet named OnlineCockpit Generated Sheet.
I have been manually copying cells B32:J81 from this sheet. Because I would be copying from 5 different spreadsheets I thought it better to leave the copy out and do that manually.

2 - the error is "Run-time error '1004': Application-defined or object-defined error"

Hope this helps.
 
Upvote 0
Code:
With Sheets("Control")
    .Range("d8").PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:= _
False
End With

With the above, you are using the Range PasteSpecial method. The Range PasteSpecial method has no format, link, or DisplayAsIcon parameters. Hence the runtime 1004 error. The Format, link, or DisplayAsIcon parameters *DO* exist for the Worksheet PasteSpecial method. The simplest solution might be to just paste values

Code:
With Sheets("Control")
    .Range("d8").PasteSpecial xlPasteAll
End With

But you can use the worksheet PasteSpecial method so long as you select the destination range first
Code:
Sub TextBox1_Click()
'
' TextBox1_Click Macro
' Paste into Monday
'
'
With Sheets("Control")
    .Range("d8").select
    .PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:=False
End With
End Sub

Note that the data you paste using worksheet.pastespecial has to be in the windows clipboard.
 
Upvote 0
HI Rlv

All sorted now. Thank you very much!!!!! :):)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,921
Messages
6,122,280
Members
449,075
Latest member
staticfluids

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