For Loops and Named ranges

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have ranges named in my worksheet (ques1, ques2, etc) and I would like to
use a loop to clear the contents of these ranges.

Something like:
For i = 1 To 60
Range("ques i ").Select
Selection.ClearContents
Next i
End Sub

Any suggestions on how to make this work?
 
if you want to clear all of the ranges

Option Explicit
Dim nm As Name

Sub Clear_rnge()
For Each nm In ThisWorkbook.Names
Range(nm).ClearContents
Next
End Sub
 
Back
Top