ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete all entries in selection except activecell (https://www.excelbanter.com/excel-programming/325063-delete-all-entries-selection-except-activecell.html)

Elaine

Delete all entries in selection except activecell
 
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.

Naomi

Delete all entries in selection except activecell
 
Best bet is something like:

dim active_val as string

active_val = activecell.value

with selection
..clearcontents
end with

activecell.value = active_val


"Elaine" wrote:

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.


Elaine

Delete all entries in selection except activecell
 
Thank you very much for your help.

"Naomi" wrote:

Best bet is something like:

dim active_val as string

active_val = activecell.value

with selection
.clearcontents
end with

activecell.value = active_val


"Elaine" wrote:

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.


Tom Ogilvy

Delete all entries in selection except activecell
 
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

--
Regards,
Tom Ogilvy


"Elaine" wrote in message
...
Thank you very much for your help.

"Naomi" wrote:

Best bet is something like:

dim active_val as string

active_val = activecell.value

with selection
.clearcontents
end with

activecell.value = active_val


"Elaine" wrote:

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.





All times are GMT +1. The time now is 03:25 PM.

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