PC Review


Reply
Thread Tools Rate Thread

Auto Update Cell (Row) References

 
 
joecrabtree
Guest
Posts: n/a
 
      6th Dec 2006
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

 
Reply With Quote
 
 
 
 
Zone
Guest
Posts: n/a
 
      6th Dec 2006
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


 
Reply With Quote
 
joecrabtree
Guest
Posts: n/a
 
      7th Dec 2006
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" <jkend69...@aol.com> 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 With Quote
 
Zone
Guest
Posts: n/a
 
      8th Dec 2006
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" <jkend69...@aol.com> 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 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
How to auto update references? Al Microsoft Word Document Management 1 8th Aug 2007 02:14 AM
Cell references auto update when sorting Chris Microsoft Excel Misc 3 8th Mar 2007 04:34 PM
Auto-Update References Martin Schneider Microsoft Access Form Coding 1 19th Jan 2007 03:02 PM
Re: Auto Update remote references NavyKnight Microsoft Excel Worksheet Functions 3 15th Jan 2004 06:59 PM
Auto Update remote references acw Microsoft Excel Worksheet Functions 0 21st Jul 2003 03:35 AM


Features
 

Advertising
 

Newsgroups
 


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