Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Auto Update Cell (Row) References

To all,

I have a macro that refers to a range eg:

Range.("P2:P100")

However I want to be able to change this range depending on what the
user enters in a cell ( A1). SO for example if the user enters '200'
the Range will be ("P2: P200"), or if the user enters 50 the range will
be ("P2:P50") etc.

Any help on this would be much appreciated. Thanks

Joseph Crabtree

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Auto Update Cell (Row) References

Joe, try this:
Dim myRg As String
myRg = "P2:P" & CStr([A1])
James

joecrabtree wrote:
To all,

I have a macro that refers to a range eg:

Range.("P2:P100")

However I want to be able to change this range depending on what the
user enters in a cell ( A1). SO for example if the user enters '200'
the Range will be ("P2: P200"), or if the user enters 50 the range will
be ("P2:P50") etc.

Any help on this would be much appreciated. Thanks

Joseph Crabtree


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Auto Update Cell (Row) References

Thanks for that. I have now got it to work.

using:

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

Set ws = Sheets("FINAL Averages")

Set r = Range(myRg)



I have another question, is it possible to change this so that I can
define both starting and finishing cells? I tried adding another string
but it didn't work. Any ideas?

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




On Dec 6, 3:20 pm, "Zone" wrote:
Joe, try this:
Dim myRg As String
myRg = "P2:P" & CStr([A1])
James



joecrabtree wrote:
To all,


I have a macro that refers to a range eg:


Range.("P2:P100")


However I want to be able to change this range depending on what the
user enters in a cell ( A1). SO for example if the user enters '200'
the Range will be ("P2: P200"), or if the user enters 50 the range will
be ("P2:P50") etc.


Any help on this would be much appreciated. Thanks


Joseph Crabtree- Hide quoted text -- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Auto Update Cell (Row) References

Joe, there shouldn't be any problem with concatenating the range like
this:
myRg = "J" & CStr(Range("D3")) & ":J" & CStr(Range("D10"))
James
joecrabtree wrote:
Thanks for that. I have now got it to work.

using:

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

Set ws = Sheets("FINAL Averages")

Set r = Range(myRg)



I have another question, is it possible to change this so that I can
define both starting and finishing cells? I tried adding another string
but it didn't work. Any ideas?

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




On Dec 6, 3:20 pm, "Zone" wrote:
Joe, try this:
Dim myRg As String
myRg = "P2:P" & CStr([A1])
James



joecrabtree wrote:
To all,


I have a macro that refers to a range eg:


Range.("P2:P100")


However I want to be able to change this range depending on what the
user enters in a cell ( A1). SO for example if the user enters '200'
the Range will be ("P2: P200"), or if the user enters 50 the range will
be ("P2:P50") etc.


Any help on this would be much appreciated. Thanks


Joseph Crabtree- Hide quoted text -- Show quoted text -


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
Automatic update to SUM formula cell references. David S[_2_] Excel Worksheet Functions 6 April 21st 10 12:21 PM
Auto Update worksheet references as new worksheets are added Rick Excel Worksheet Functions 1 January 12th 09 10:00 PM
how do i auto update cell values after pasting linked references kev Excel Worksheet Functions 0 December 6th 07 05:09 PM
Cell references auto update when sorting Chris Excel Discussion (Misc queries) 3 March 8th 07 04:34 PM
Cell references do not update ivan Excel Discussion (Misc queries) 4 October 28th 06 10:34 AM


All times are GMT +1. The time now is 04:09 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"