Insert / Name / Define

G

Guest

I have a macro that should delete the contents of a named range, but it's not
deleting cell H17. In the Refers to box the range is defined as
='Sheet1'$H$10:$H$17. H10 through H16 deletes, but I have to manually delete
H17. What goes here?

Thanks.
 
N

Niek Otten

Your code?

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

|I have a macro that should delete the contents of a named range, but it's not
| deleting cell H17. In the Refers to box the range is defined as
| ='Sheet1'$H$10:$H$17. H10 through H16 deletes, but I have to manually delete
| H17. What goes here?
|
| Thanks.
 
G

Guest

I have a macro that should delete the contents of a named range, but it's not
deleting cell H17. In the Refers to box the range is defined as
='Sheet1'$H$10:$H$17. H10 through H16 deletes, but I have to manually delete
H17. What goes here?

How is it really defined? The expression above is a syntax error since
there's no ! between the worksheet name and the range address. You may
believe it's defined to span H10:H17, but double check.

Also, are you using .Clear or .ClearContents method calls? What's the actual
macro statement you're using that doesn't work?
 
G

Guest

Sorry for the typo... ='Sheet 1'!$H$10:$H$17

It's doing as it should for all but cell H17
 
G

Guest

Sub Clear_Click()
If ActiveSheet.ProtectContents Then
ActiveSheet.Unprotect
Range("Timedata").ClearContents
Range("Timedata2").ClearContents
Range("Afterhours").ClearContents
Range("TimeComments").ClearContents
Range("HolidayTaken").ClearContents



ActiveSheet.Protect _
DrawingObjects:=True, _
Contents:=True
Else
Range("Timedata").ClearContents
Range("Timedata2").ClearContents
Range("Afterhours").ClearContents
Range("TimeComments").ClearContents
Range("HolidayTaken").ClearContents
End If
End Sub
 

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

Similar Threads


Top