Forum

Range.ClearContents...
 
Notifications
Clear all

Range.ClearContents with Worksheet_Activate() event

2 Posts
2 Users
0 Reactions
86 Views
(@Anonymous)
Posts: 0
New Member Guest
 

Has anyone noticed this anomaly?

Put the following into the sheet1 code window:

Private Sub Worksheet_Activate()
Sheets("Sheet1").Range("A1").ClearContents
End Sub

Now enter something into Sheet1 cell A1.

Select A1. Note that the contents appears in the formula bar, as expected.

With A1 still selected on sheet1, select another sheet, then go back to sheet1

Cell A1 is cleared, but the contents is left in the formula bar.

As soon as a different cell is selected, the formula bar is cleared.

It doesn't seem to create any issues, but a bit disconcerting when returning to a sheet that should have a clear cell.

Interestingly, if I use Sheets("Sheet1").Range("A1") = "" in the event macro, this doesn't occur.

 
Posted : 27/10/2016 11:08 pm
Philip Treacy
(@philipt)
Posts: 1632
Member Admin
 

Hi Dave,

I had not seen this before but I can reproduce it.  Also, if you leave A1 selected, click in the formula bar, then hit Enter, the data is entered back into A1.

So it looks like the formula bar contents are not being cleared, which I would consider a bug.

We'll raise this with Microsoft.

Thanks

Phil

 
Posted : 28/10/2016 8:53 pm
Share: