ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clearing a column (https://www.excelbanter.com/excel-programming/300861-clearing-column.html)

grovesy

Clearing a column
 
Hi all,

This question is in two parts.

1) How do you clear an entire column of date in vb code?
2)Is it possible to clear an entire column excluding some cells withi
that colume? For example;

Lets say i want to clear column "A" but want to exclude "A1" and "A2
from this clear function

Is this possible? How!

Cheers al

--
Message posted from http://www.ExcelForum.com


Norman Jones

Clearing a column
 
Hi Grovessy,

To delete contents and format:

1) Columns(1).Clear

2) Columns(1).Rresize(Rows.Count-2).Offset(2).Clear

To delete contents but retain formatting, replace Clear with ClearContents.


---
Regards,
Norman.


"grovesy " wrote in message
...
Hi all,

This question is in two parts.

1) How do you clear an entire column of date in vb code?
2)Is it possible to clear an entire column excluding some cells within
that colume? For example;

Lets say i want to clear column "A" but want to exclude "A1" and "A2"
from this clear function

Is this possible? How!

Cheers all


---
Message posted from http://www.ExcelForum.com/




grovesy[_2_]

Clearing a column
 
Cheers Norman,

The first method does clear the entire column :)

Unfortunately the second one (The clear column excluding some cells
give me an error;

-Object doesn't support this property or method-

Any ideas?

Thanks agai

--
Message posted from http://www.ExcelForum.com


Norman Jones

Clearing a column
 
Hi Grovesy,

A typo! Change:

Columns(1).Rresize(Rows.Count-2).Offset(2).Clear

to:

Columns(1).Resize(Rows.Count-2).Offset(2).Clear

---
Regards,
Norman


"grovesy " wrote in message
...
Cheers Norman,

The first method does clear the entire column :)

Unfortunately the second one (The clear column excluding some cells)
give me an error;

-Object doesn't support this property or method-

Any ideas?

Thanks again


---
Message posted from http://www.ExcelForum.com/




Cecilkumara Fernando[_2_]

Clearing a column
 

"grovesy " wrote in message
...
Hi all,

This question is in two parts.

1) How do you clear an entire column of date in vb code?


range("A1").EntireColumn.ClearContents

2)Is it possible to clear an entire column excluding some cells within
that colume? For example;

Lets say i want to clear column "A" but want to exclude "A1" and "A2"
from this clear function


range("A3","A65536").ClearContents

you can add ranges with Union
union(range("C1","C30"),range("C32","C65536")).Cle arContents

HTH
Cecil



grovesy[_3_]

Clearing a column
 
Thanks Norman,

I should have spotted that!

You've been a great help

Chri

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 09:08 PM.

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