worksheet deactivate not working

Chewyhairball

Active Member
Joined
Nov 30, 2017
Messages
312
Office Version
  1. 365
Platform
  1. Windows
Hi

I am trying to run this code to delete constants from column I when i leave a sheet.

Private Sub Worksheet_Deactivate()

Columns("I:I").Select
Selection.SpecialCells(xlCellTypeConstants, 2).Select
Selection.ClearContents
End Sub


The code runs fine using a button but if i try to run it using worksheet deactivate i get an error

"select method of range class failed" and debugging highlights "Columns("I:I").Select"

any help would be most appreciated

thanks

Rory
 
Thanks.

I am in the far north of Scotland. Its actually a beautiful sunny day today here so I am off outside to get some.

Thanks again.

Rory
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Wow. Must be beautiful there.
I have been to most parts of Western Europe but never Scotland.
I'm here in central Florida 76 degrees F at 6:34 AM
 
Upvote 0
I guess its not bad here. We holiday'd to Florida for about 10 years in a row. Haven't been for a few years now but was like our second home for a while.

Great fun! I do like a good coaster!

OK..you win on the temperature stakes...thats toasty.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top