PC Review


Reply
Thread Tools Rate Thread

Change Range using value in cell

 
 
joecrabtree
Guest
Posts: n/a
 
      8th Dec 2006
To all,



At the moment my macro uses the code below, so that the value in D10
changes the range selected. However is it possible to change bot the
starting row number as well as the finish row number?

Thanks

Joseph


myRg = "J2:J" & CStr(Range("D10"))


Set ws = Sheets("FINAL Averages")


Set r = Range(myRg)




i.e if I enter 3 into D9, and 10 into D10 it will give the range
J3:J10?


Thanks for your help,


Regards


Joseph Crabtree

 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      8th Dec 2006
Joseph,
Here's one way. Note that all the Cells and Range objects are relative to WS
i.e. they are preceeded by a "."
If you D9 & D10 values are not on that sheet, adjust accordingly.

Dim WS As Worksheet
Dim r As Range

Set WS = Sheets("FINAL Averages")
With WS
Set r = .Range(.Cells(.Range("D9").Value, "J"),
..Cells(.Range("D10").Value, "J"))
End With

NickHK

"joecrabtree" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> To all,
>
>
>
> At the moment my macro uses the code below, so that the value in D10
> changes the range selected. However is it possible to change bot the
> starting row number as well as the finish row number?
>
> Thanks
>
> Joseph
>
>
> myRg = "J2:J" & CStr(Range("D10"))
>
>
> Set ws = Sheets("FINAL Averages")
>
>
> Set r = Range(myRg)
>
>
>
>
> i.e if I enter 3 into D9, and 10 into D10 it will give the range
> J3:J10?
>
>
> Thanks for your help,
>
>
> Regards
>
>
> Joseph Crabtree
>



 
Reply With Quote
 
Kweenie
Guest
Posts: n/a
 
      8th Dec 2006
Hi Joseph

Something like this??

myRg = "J" & CStr(Range("D9")) & ":J" & CStr(Range("D10"))
Set ws = Sheets("FINAL Averages")
Set r = Range(myRg)
Range(myRg).Select

Regards

Piet

joecrabtree schreef:

> To all,
>
>
>
> At the moment my macro uses the code below, so that the value in D10
> changes the range selected. However is it possible to change bot the
> starting row number as well as the finish row number?
>
> Thanks
>
> Joseph
>
>
> myRg = "J2:J" & CStr(Range("D10"))
>
>
> Set ws = Sheets("FINAL Averages")
>
>
> Set r = Range(myRg)
>
>
>
>
> i.e if I enter 3 into D9, and 10 into D10 it will give the range
> J3:J10?
>
>
> Thanks for your help,
>
>
> Regards
>
>
> Joseph Crabtree


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change 3rd cell colour based on cell 1 >= cell2 in range wombarrapete Microsoft Excel Discussion 8 21st Dec 2008 09:41 PM
Evaluate cell in range and change cell attribute S Himmelrich Microsoft Excel Programming 4 11th Apr 2008 06:06 PM
How do I change cell color based upon data range within the cell? =?Utf-8?B?Q2hyaXMgU2FuZGVycw==?= Microsoft Excel Worksheet Functions 1 6th Mar 2006 08:59 PM
How do I change a cell range with a reference cell? =?Utf-8?B?RGFubmVza2pvbGQ=?= Microsoft Excel Misc 2 11th Aug 2005 07:37 PM
Change cell colour for a cell or range within a predefined range =?Utf-8?B?TWFydGlu?= Microsoft Excel Programming 2 23rd May 2005 06:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:49 AM.