Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default A simpler way

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default A simpler way

On Thu, 22 Jan 2009 16:27:01 -0800, veryeavy
wrote:

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default A simpler way

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

"Ron Rosenfeld" wrote:

On Thu, 22 Jan 2009 16:27:01 -0800, veryeavy
wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default A simpler way

On Thu, 22 Jan 2009 17:32:05 -0800, veryeavy
wrote:

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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default A simpler way

On Jan 22, 8:32*pm, veryeavy
wrote:
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

"Ron Rosenfeld" wrote:
On Thu, 22 Jan 2009 16:27:01 -0800, veryeavy
wrote:


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


Dim x as Integer

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

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
VBA code simpler? mohavv Excel Discussion (Misc queries) 4 December 2nd 07 06:39 AM
is there not a simpler way T.c.Goosen1977[_30_] Excel Programming 4 July 5th 06 08:52 AM
How can I make this simpler? Sethaholic[_10_] Excel Programming 3 July 13th 05 08:20 PM
Need to make this simpler. Jack Excel Programming 2 September 21st 04 08:21 PM
Lil Simpler ksnapp[_16_] Excel Programming 3 March 4th 04 12:32 AM


All times are GMT +1. The time now is 04:50 PM.

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

About Us

"It's about Microsoft Excel"