View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default What is the selection syntax

For many (most) actions in Excel, it is not necessary to .Select then before
you work with them.
In fact .Select slows down your code quite substantially.
So you can do the whole operation in one line

With Sheet1
.Range("A1", .Range("A1").SpecialCells(xlLastCell)).ClearConten ts 'Or
..Clear
End With

NickHK
P.S. There is only one "Selection" per Excel instance, so you cannot qualify
it with Sheet1 or a workbook. Similarly, there is only a single
ActiveWorkbook
ActiveSheet
ActiveCell

"hon123456" wrote in message
ups.com...
Dear all,

I have the following sentence which select a range, and
then I want to clear the selected area.

Sheet1.Range("A8").Select
Sheet1.Range(Selection,
ActiveCell.SpecialCells(xlLastCell)).Select

Then I want to tell excel the clear the selected area? I
write the following sentence,but it is not
work.

Sheet1.range(selection).clear

What is the right syntax to point out a selection.

Is that something like that: sheet1.selection or
sheet1.range.selection ?

Thanks