Thread: clear ranges
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Striker Striker is offline
external usenet poster
 
Posts: 55
Default clear ranges

OK, this works, I just need to be sure it only happens on the current
worksheet, not workbook.


"Stefi" wrote in message
...
Try something like this:
Sub test()
Dim n As Name
For Each n In ThisWorkbook.Names
Range(n).ClearContents
Range(n).ClearComments
Next n
End Sub

Regards,
Stefi

"Striker" ezt írta:

I have about 40 named ranges in a sheet. I need do quickly do a ,loop
and
clear all named ranges. currently I am clearing like this, but it is
getting too long to do with all the ranges. not sure how to assing a
range
name to a variable and clear it.

With ActiveSheet

Range("ONE").Select
Selection.ClearContents
Selection.ClearComments

Range("TWO").Select
Selection.ClearContents
Selection.ClearComments

Range("THREE").Select
Selection.ClearContents
Selection.ClearComments
end with