Delete all entries in selection except activecell

E

Elaine

How can I delete all entries from a selection except for the currently active
cell?

In other words, if I have selected the range (A3:a12), I would like to
retain the value of A3 but delete the contents of all other cells.

Thanks for your help.
 
N

Naomi

Best bet is something like:

dim active_val as string

active_val = activecell.value

with selection
..clearcontents
end with

activecell.value = active_val
 
E

Elaine

Thank you very much for your help.

Naomi said:
Best bet is something like:

dim active_val as string

active_val = activecell.value

with selection
.clearcontents
end with

activecell.value = active_val
 
T

Tom Ogilvy

Safer/more robust would be to user the formula property which will preserve
either formula or value

dim active_val as string

active_val = activecell.Formula

with selection
..clearcontents
end with

activecell.Formula = active_val
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top