A simpler way

  • Thread starter Thread starter veryeavy
  • Start date Start date
V

veryeavy

Hi,

Is there a more efficient was of writiing the following code:

Application.Goto Reference:="ICT1"
Selection.ClearContents

Application.Goto Reference:="ICT2"
Selection.ClearContents

Application.Goto Reference:="ICT3"
Selection.ClearContents

Application.Goto Reference:="ICT4"
Selection.ClearContents

ICT1 etc. are simply non-contiguous named ranges.

Thanks in Advance and all the best as always,

Matt
 
Hi,

Is there a more efficient was of writiing the following code:

Application.Goto Reference:="ICT1"
Selection.ClearContents

Application.Goto Reference:="ICT2"
Selection.ClearContents

Application.Goto Reference:="ICT3"
Selection.ClearContents

Application.Goto Reference:="ICT4"
Selection.ClearContents

ICT1 etc. are simply non-contiguous named ranges.

Thanks in Advance and all the best as always,

Matt

Simpler would be:

==================
Range("ICT1,ICT2,ICT3,ICT4").ClearContents
=================

However, you should be aware that these Names will not be legal in Excel 2007
in native mode, as ICT1, etc, are all valid cell references.
--ron
 
Many thanks, Ron.

Your observations re Range Names was especially useful.

So do I love my employer enough to make my code forward compatible?

That will require some pondering)

Cheers,

Matt
 
Many thanks, Ron.

Your observations re Range Names was especially useful.

So do I love my employer enough to make my code forward compatible?

That will require some pondering)

Cheers,

Matt

Glad to help.

Good luck with your pondering :-)
--ron
 
Many thanks, Ron.

Your observations re Range Names was especially useful.

So do I love my employer enough to make my code forward compatible?

That will require some pondering)

Cheers,

Matt

Dim x as Integer

For x=1 to 4
Range("ICT"&x).ClearContents
Next x
 

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

Similar Threads


Back
Top