PC Review


Reply
Thread Tools Rate Thread

Assigning cell value to range variable

 
 
Raj
Guest
Posts: n/a
 
      31st Jul 2008
Hi,

Cell a1 of Sheet3 has the value : Worksheets("Parameters").Range("d4")

I want to assing this value to a range variable named rsprange.

I am using the statement:
Set rsprange = ThisWorkbook.Worksheets("Sheet3").Range("a1").Value

I am getting error message 424: Object Required.

Please help. I have the feeling this is something elementary that I am
not able to trouble-shoot.

Thanks in advance

Regards,
Raj

PS: I had posted this earlier today under the subject : Setting range
using vlookup. I am restating the problem after stripping extraneous
matter.
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      31st Jul 2008
You're going to have to parse the contents of that cell to extract the worksheet
name and the address.

After you do that, you can use:

dim wksName as string
dim RngAddr as string
....some routine to parse those strings
set rsprange = thisworkbook.worksheets(wksname).range(rngaddr)

===
If I were you, I'd use two cells--one for the worksheet name and one for the
address of the cell.

with thisworkbook.worksheets("sheet3")
set rsprange = thisworkbook.worksheets(.range("b1").value) _
.range(.range("C1").value)
end with

Depending on what the name of that sheet and the address, it could make life
lots easier.


Raj wrote:
>
> Hi,
>
> Cell a1 of Sheet3 has the value : Worksheets("Parameters").Range("d4")
>
> I want to assing this value to a range variable named rsprange.
>
> I am using the statement:
> Set rsprange = ThisWorkbook.Worksheets("Sheet3").Range("a1").Value
>
> I am getting error message 424: Object Required.
>
> Please help. I have the feeling this is something elementary that I am
> not able to trouble-shoot.
>
> Thanks in advance
>
> Regards,
> Raj
>
> PS: I had posted this earlier today under the subject : Setting range
> using vlookup. I am restating the problem after stripping extraneous
> matter.


--

Dave Peterson
 
Reply With Quote
 
Raj
Guest
Posts: n/a
 
      31st Jul 2008
Dave,

Exactly the pointers I was looking for.

I have adopted the "If I were you" approach.

Thanks, once again.

Regards,
Raj

Dave Peterson wrote:

> You're going to have to parse the contents of that cell to extract the worksheet
> name and the address.
>
> After you do that, you can use:
>
> dim wksName as string
> dim RngAddr as string
> ...some routine to parse those strings
> set rsprange = thisworkbook.worksheets(wksname).range(rngaddr)
>
> ===
> If I were you, I'd use two cells--one for the worksheet name and one for the
> address of the cell.
>
> with thisworkbook.worksheets("sheet3")
> set rsprange = thisworkbook.worksheets(.range("b1").value) _
> .range(.range("C1").value)
> end with
>
> Depending on what the name of that sheet and the address, it could make life
> lots easier.
>
>
> Raj wrote:
> >
> > Hi,
> >
> > Cell a1 of Sheet3 has the value : Worksheets("Parameters").Range("d4")
> >
> > I want to assing this value to a range variable named rsprange.
> >
> > I am using the statement:
> > Set rsprange = ThisWorkbook.Worksheets("Sheet3").Range("a1").Value
> >
> > I am getting error message 424: Object Required.
> >
> > Please help. I have the feeling this is something elementary that I am
> > not able to trouble-shoot.
> >
> > Thanks in advance
> >
> > Regards,
> > Raj
> >
> > PS: I had posted this earlier today under the subject : Setting range
> > using vlookup. I am restating the problem after stripping extraneous
> > matter.

>
> --
>
> Dave Peterson

 
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
Assigning a cell address to a variable James Microsoft Excel Programming 1 12th Feb 2010 02:05 PM
Runtime error 9 subscript out of range - assigning array to variable mark Stephens Microsoft Excel Programming 0 26th Jul 2009 04:20 PM
Assigning Variable Range =?Utf-8?B?Sk1heQ==?= Microsoft Excel Misc 1 7th Jul 2007 04:52 PM
assigning a letter in a cell from a range of numbers in another ce =?Utf-8?B?ZGJh?= Microsoft Excel Programming 2 23rd May 2007 04:43 PM
Assigning a variable a value from a Cell in VBA jefflck@comcast.net Microsoft Excel Programming 3 15th Feb 2006 06:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:58 PM.