View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default Debug error 1004

"Selection" is a property of the Application or a specified Window.
So you need...
Selection.ClearContents.

You can make your programming more efficient by not selecting
objects before applying code to them...
'--
With Sheets("Original")
.Range("A9", .Range("A9").End(xlToRight).End(xlDown)).ClearCont ents
End With
--
Jim Cone
Portland, Oregon USA



"Kasper"

wrote in message
Hi again
I have build a little bit on the macro and run into another error. The
Sheets("Original").Selection.ClearContents is not allowed and gives me
another error. Is there any other way to clear the selection before i
copy my new data?

Private Sub button2_Click()
Sheets("Original").Select
Sheets("Original").Range("A9").Select
Sheets("Original").Range(Selection, Selection.End
(xlToRight)).Select
Sheets("Original").Range(Selection, Selection.End(xlDown)).Select
Sheets("Original").Selection.ClearContents

Sheets("Front").Select
Range("B18").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Original").Select
Sheets("Original").Range("A9").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub

/Kasper