Trouble pasting from clip board

  • Thread starter Thread starter RITCHI
  • Start date Start date
R

RITCHI

I'm trying to clear a range and then paste data from the clip board
into the worksheet.
The data on the clip board is copied from another application.
Ive tried the script below without success.

Sub ClearAndPasteImportedData()
'Select top left cell of data input range and paste contents of clip
board
Dim RangeToFormat As Range
Set RangeToFormat = Range("a6:f3000")
RangeToFormat.Select
Selection.Clear
Range("a6").Select.Paste
End Sub

Any help would be appreciated.

Ritchi
 
Maybe...

Option Explicit
Sub ClearAndPasteImportedData()
'Select top left cell of data input range and paste contents of clip board
Dim RangeToFormat As Range
Set RangeToFormat = Range("a6:f3000")
RangeToFormat.Clear
RangeToFormat.Cells(1).PasteSpecial
End Sub
 
try it this way
Sub copyfromclipboard()
Range("a6:a6000") = "" '.Clear
Range("a6").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub
 
To delete the extra rows created, use this instead.

Sub copyfromclipboard1()
Range("a6:a6000") = "" '.Clear
Range("a6").Select
ActiveSheet.Paste
Application.CutCopyMode = False
x = Cells(Rows.Count, "f").End(xlUp).Row
Rows(x & ":6000").Delete
End Sub
 
Thanks Don

This works but not every time; it only seems to work when the marching
ants are around the area cut. This is not the case when I bring data
in from outside of Excel.
 
Back
Top