Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default What is the selection syntax

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default What is the selection syntax

Sheet1.Range("A8").CurrentRegion.Clear

--
Regards,
Tom Ogilvy


"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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default What is the selection syntax

tom:

when i have values in a1 thru a15 and use your code, it deletes everything
in column a, not just a8:a15.

is this right?

--


Gary


"Tom Ogilvy" wrote in message
...
Sheet1.Range("A8").CurrentRegion.Clear

--
Regards,
Tom Ogilvy


"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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default What is the selection syntax

this is one way

Sub test()
With Sheet1.Range("a8", ActiveCell.SpecialCells(xlLastCell))
.Clear
End With
End Sub

--


Gary


"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


  #5   Report Post  
Posted to microsoft.public.excel.programming
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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default What is the selection syntax

Yes it is. CurrentRegion region is the range bounded by any combination of
blank rows and blank columns (or spreadsheet edges), down, up, left and
right.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"GKeramidas" wrote in message
...
tom:

when i have values in a1 thru a15 and use your code, it deletes everything
in column a, not just a8:a15.

is this right?

--


Gary


"Tom Ogilvy" wrote in message
...
Sheet1.Range("A8").CurrentRegion.Clear

--
Regards,
Tom Ogilvy


"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






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default What is the selection syntax

Sure, that is what currentregion is all about. But

In contrast, if row 7 is blank, then it doesn't.

but

set rng1 = Sheet1.Range("A8").CurrentRegion
sheet1.Range("A8",rng1(rng1.count)).Clear

or if the data isn't contiguous

set rng1 = Sheet1.UserRange
sheet1.Range("A8"),rng1(rng1.count)).Clear

or
With Worksheets("Sheet1")
.Range(.Cells(8,1),.cells(rows.count,columns.count )).EntireRow.Clear
End With




--
Regards,
Tom Ogilvy



"GKeramidas" wrote in message
...
tom:

when i have values in a1 thru a15 and use your code, it deletes everything
in column a, not just a8:a15.

is this right?

--


Gary


"Tom Ogilvy" wrote in message
...
Sheet1.Range("A8").CurrentRegion.Clear

--
Regards,
Tom Ogilvy


"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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Limiting selection in a cell AND linking that selection to a list Lisa Excel Discussion (Misc queries) 1 July 28th 09 05:00 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
syntax for range selection saziz[_58_] Excel Programming 2 January 5th 06 08:37 PM
Object Type of a selection... counting rows in a selection Acid-Sky[_2_] Excel Programming 3 August 23rd 05 09:53 AM
Syntax - Add Range Name based on Selection Bruce Roberson Excel Programming 2 August 8th 03 10:13 PM


All times are GMT +1. The time now is 01:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"