How to create a Macro to delete selected data?


Posted by Mark on January 19, 2002 7:16 AM

Can anyone tell me the code for a macro that deletes the data that is selected at the time the macro is run?

Posted by Pandarus on January 19, 2002 7:29 AM

Selection.ClearContents (which you could have got from the macro recorder)

Posted by Earl on January 19, 2002 7:29 AM

Selection.ClearContents
End Sub

Posted by Mark on January 19, 2002 7:36 AM

Ok cheers, so how would i now go about making a macro to delete the 4 cells to the right of the selected cell aswell?



Posted by Pandarus on January 19, 2002 7:57 AM


To clear the contents of the 4 cells to the immediate right of the selected cell :-
Selection.Offset(0, 1).Resize(, 4).ClearContents

To clear the selected cell and the 4 cells to the immediate right of the selected cell :-
Selection.Resize(, 5).ClearContents

Or, you can select all 5 cells then use Selection.ClearContents