ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to clear a selection (https://www.excelbanter.com/excel-programming/292561-how-clear-selection.html)

Nathan Gutman

How to clear a selection
 
I need to determine the last cell with data in column A then clear
contents from the last three cells in that column.
What is a simple way to do that?
Thanks..

Ron de Bruin

How to clear a selection
 
Hi Nathan

Try this

Sub test()
Dim Lr As Long
With Sheets("sheet1")
Lr = .Range("A" & Rows.Count).End(xlUp).Row
..Range(.Cells(Lr - 2, "A"), .Cells(Lr, "A")).ClearContents
End With
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Nathan Gutman" wrote in message ...
I need to determine the last cell with data in column A then clear
contents from the last three cells in that column.
What is a simple way to do that?
Thanks..




Bob Phillips[_6_]

How to clear a selection
 
Good Evening Nathan,

A simple one-liner

Worksheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Offset(-2,
0).Resize(3, 1).ClearContents

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Nathan Gutman" wrote in message
...
I need to determine the last cell with data in column A then clear
contents from the last three cells in that column.
What is a simple way to do that?
Thanks..




Nathan Gutman

How to clear a selection
 
Thank you guys.
On Wed, 25 Feb 2004 20:34:52 -0000, "Bob Phillips"
wrote:

Good Evening Nathan,

A simple one-liner

Worksheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Offset(-2,
0).Resize(3, 1).ClearContents



Nathan Gutman

How to clear a selection
 
Hello Bob,
You one-liner worked beautifully! In my case I just used
ActiveSheet.Cells(...
Would you care to explain what is doing what here.
Thanks again,
Nathan
On Wed, 25 Feb 2004 20:34:52 -0000, "Bob Phillips"
wrote:

Good Evening Nathan,

A simple one-liner

Worksheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Offset(-2,
0).Resize(3, 1).ClearContents




All times are GMT +1. The time now is 02:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com