Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default 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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default 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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Like 123, allow named ranges, and print named ranges WP Excel Discussion (Misc queries) 1 April 8th 05 06:07 PM
named ranges - changing ranges with month selected gr8guy Excel Programming 2 May 28th 04 04:50 AM
named ranges, I think inquirer Excel Programming 2 May 4th 04 03:27 AM
Ranges / Loops fabalicious[_13_] Excel Programming 4 April 21st 04 11:10 AM
Named ranges Bob Phillips[_6_] Excel Programming 0 April 20th 04 04:08 PM


All times are GMT +1. The time now is 11:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"