Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default VBA code to delete cell contents

How does everybody write code to delete the contents of
a cell, such as cell "A1"???

I normally use the following code:

Range("A1").Value = ""

Is that correct?? I get the feeling that I am setting cell "A1"
to an empty string, rather than actually deleting the current
contents.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default VBA code to delete cell contents

Hi Robert

Your method works. Here is another method which gets the job done as
well.

Range("A1").ClearContents

Take care

Marcus
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default VBA code to delete cell contents

Hi

When I delete the contents of a single cell, I usually use .Value="" as you
do, but when I want to delete contents multiple cells, I use .ClearContents
which delete the content of the cells.

Using .Clear will not only delete the content but also clear any formating
in the cell(s).

Regards,
Per

"Robert Crandal" skrev i meddelelsen
...
How does everybody write code to delete the contents of
a cell, such as cell "A1"???

I normally use the following code:

Range("A1").Value = ""

Is that correct?? I get the feeling that I am setting cell "A1"
to an empty string, rather than actually deleting the current
contents.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default VBA code to delete cell contents

..Value = "" works on multiple cells as well..

"Per Jessen" wrote:

Hi

When I delete the contents of a single cell, I usually use .Value="" as you
do, but when I want to delete contents multiple cells, I use .ClearContents
which delete the content of the cells.

Using .Clear will not only delete the content but also clear any formating
in the cell(s).

Regards,
Per

"Robert Crandal" skrev i meddelelsen
...
How does everybody write code to delete the contents of
a cell, such as cell "A1"???

I normally use the following code:

Range("A1").Value = ""

Is that correct?? I get the feeling that I am setting cell "A1"
to an empty string, rather than actually deleting the current
contents.



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default VBA code to delete cell contents

I know that .Value="" work on multiple cells, but i prefer to use
..ClearContents when working with multiple cells.

"Jacob Skaria" skrev i meddelelsen
...
.Value = "" works on multiple cells as well..

"Per Jessen" wrote:

Hi

When I delete the contents of a single cell, I usually use .Value="" as
you
do, but when I want to delete contents multiple cells, I use
.ClearContents
which delete the content of the cells.

Using .Clear will not only delete the content but also clear any
formating
in the cell(s).

Regards,
Per

"Robert Crandal" skrev i meddelelsen
...
How does everybody write code to delete the contents of
a cell, such as cell "A1"???

I normally use the following code:

Range("A1").Value = ""

Is that correct?? I get the feeling that I am setting cell "A1"
to an empty string, rather than actually deleting the current
contents.



.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default VBA code to delete cell contents

For Excel VBA you can try the clearcontents method for a Range

Range("A1").ClearContents

Range("A1")="" does the same as Range("A1") = vbNullString

When you mention Range("A1")="" the computer generate a null string....and
then assign that value to the cell; whereas vbNullString is a null string and
so should be quicker.


If this post helps click Yes
---------------
Jacob Skaria


"Robert Crandal" wrote:

How does everybody write code to delete the contents of
a cell, such as cell "A1"???

I normally use the following code:

Range("A1").Value = ""

Is that correct?? I get the feeling that I am setting cell "A1"
to an empty string, rather than actually deleting the current
contents.


.

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
delete contents of cell RDC Excel Discussion (Misc queries) 1 January 21st 09 04:13 PM
Delete cell contents Rob[_4_] Excel Discussion (Misc queries) 7 April 10th 07 12:34 PM
Delete Cell Contents IF joecrabtree Excel Programming 3 December 18th 06 02:21 PM
Delete all contents of cell but one word Hayette Hasham Excel Discussion (Misc queries) 5 January 18th 06 08:20 AM
Delete row based on contents of cell AndyG Excel Discussion (Misc queries) 6 November 17th 05 10:08 PM


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

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

About Us

"It's about Microsoft Excel"