Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Defining a range

Is it possible to define a particular range of cells so that you can just refer to the range name in the code? This is what I tried, however it didn't work. Also, if I can do this, when I use it in the code would I just put " selectrng.value = "" "if I want it to clear out all of the values in the range? Thanks. I tried it with parentheses and without and it still wouldn't work.


Dim selectrng as Range "D10:D15,F10:F15,H10:H15"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Defining a range

Dim selectrng as Range

Set selectrng = Range("D10:D15,F10:F15,H10:H15")

selectrng.Value = ""

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Matt" wrote in message
...
Is it possible to define a particular range of cells so that you can just

refer to the range name in the code? This is what I tried, however it didn't
work. Also, if I can do this, when I use it in the code would I just put "
selectrng.value = "" "if I want it to clear out all of the values in the
range? Thanks. I tried it with parentheses and without and it still wouldn't
work.


Dim selectrng as Range "D10:D15,F10:F15,H10:H15"



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Defining a range

Matt,

Try this:

Sub TestMe()
Dim selrange As Range
Set selrange = Range("D10:D15,F10:F15,H10:H15")
selrange.Activate
End Sub

The .Activate is just to show you that the range exists as
it isn't a named range (it won't show up on your range list).

If you want it named, use something like this:
selrange.Name = "testrange"

John


"Matt" wrote in message
...
Is it possible to define a particular range of cells so that you can just

refer to the range name in the code? This is what I tried, however it didn't
work. Also, if I can do this, when I use it in the code would I just put "
selectrng.value = "" "if I want it to clear out all of the values in the
range? Thanks. I tried it with parentheses and without and it still wouldn't
work.


Dim selectrng as Range "D10:D15,F10:F15,H10:H15"



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Defining a range

Matt,

Try something like

Dim Rng As Range
Set Rng = Range("D10:D15,F10:F15,H10:H15")
Rng.ClearContents


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Matt" wrote in message
...
Is it possible to define a particular range of cells so that

you can just refer to the range name in the code? This is what I
tried, however it didn't work. Also, if I can do this, when I
use it in the code would I just put " selectrng.value = "" "if I
want it to clear out all of the values in the range? Thanks. I
tried it with parentheses and without and it still wouldn't work.


Dim selectrng as Range "D10:D15,F10:F15,H10:H15"



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
Defining Range Name anshu[_2_] Excel Discussion (Misc queries) 2 July 22nd 07 07:30 AM
Defining a range Don Excel Worksheet Functions 1 February 25th 05 03:54 PM
Defining Range Question? Michael168[_58_] Excel Programming 6 November 9th 03 02:52 PM
Defining Range Extent Nigel[_4_] Excel Programming 2 October 5th 03 12:10 PM
Defining Range MAB[_5_] Excel Programming 2 September 15th 03 02:48 PM


All times are GMT +1. The time now is 03:16 AM.

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"