For Loops and Named ranges
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? |
For Loops and Named ranges
Give this a whirl...
For i = 1 To 60 Range("ques " & i).ClearContents Next i End Sub -- HTH... Jim Thomlinson "Ronnie" wrote: 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? |
For Loops and Named ranges
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 -- Gary "Ronnie" wrote in message ... 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? |
All times are GMT +1. The time now is 11:50 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com