Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Change Range using value in cell

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Change Range using value in cell

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" wrote in message
oups.com...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Change Range using value in cell

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
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
if then, change value of a cell range jo8502 New Users to Excel 1 October 28th 10 09:34 PM
How to Run VBA Code on cell or range change Dave Peterson Excel Programming 0 December 8th 06 12:05 AM
How do I change cell color based upon data range within the cell? Chris Sanders Excel Worksheet Functions 1 March 6th 06 08:59 PM
How do I change a cell range with a reference cell? Danneskjold Excel Discussion (Misc queries) 2 August 11th 05 07:37 PM
Change cell colour for a cell or range within a predefined range Martin[_21_] Excel Programming 2 May 23rd 05 06:16 PM


All times are GMT +1. The time now is 01:28 AM.

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"