For Loops and Named ranges

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?
 
G

Gary Keramidas

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
 

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

Top