Clearing a column

G

grovesy

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
 
N

Norman Jones

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.
 
G

grovesy

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
 
N

Norman Jones

Hi Grovesy,

A typo! Change:

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

to:

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

Cecilkumara Fernando

grovesy > said:
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")).ClearContents

HTH
Cecil
 
Top