Trouble pasting from clip board

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
 
D

Dave Peterson

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
 
D

Don Guillett

try it this way
Sub copyfromclipboard()
Range("a6:a6000") = "" '.Clear
Range("a6").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub
 
D

Don Guillett

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
 
R

RITCHI

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top