Problem
A dataview sheet I'm working on regularly wants to reset the contents of parts of the view (to be blank). Historically, we've had problems with users saying this sheet clears their system clipboard.
It looks like there's a problem with using Range.ClearContents
to clear these values.
# Grab some data from cells onto the clipboard
Sub ClearTheClipboardWhenTheUserIsntExpectingIt()
Cells(1, 1).EntireRow.ClearContents ' Or something like that
End Sub
This should be enough to replicate the problem.
Workaround
My question is about a possible workaround, which is to do:
Dim r as Range
...
r.Value2 = Empty
Question(s)
- Is there some obvious reason why this is not a reasonable workaround?
- Is there some more canonical way to clear the contents of a set of cells without clearing the clipboard?
- Am I just using
ClearContents
wrong?
I'm loathed to go through a large codebase and search/replace this behaviour if it's going to turn out later that I have to go back and fix it because I've introduced some bug.
Edit: I should mention that I'm using Excel 2007