PC Review


Reply
Thread Tools Rate Thread

checking and setting a value to a range in VBA

 
 
LetMeDoIt
Guest
Posts: n/a
 
      1st May 2009
Greetings,
I'm trying to do an easy thing (I think) but have not succeeded thus
far.

I created a name range manually in a spreadsheet, but need to check
via VBA code for the value of that range, then if it changed to its
default, reset that range to a specific value.

To check the that the row has not changed, I do the following: iRow =
Range("=MyRange").Row
and thus if this is not my original value, I reassigned it ( this is
where I'm getting an error msg in the code).

I'm using excel 2003.

Many thanks.
CG
 
Reply With Quote
 
 
 
 
LetMeDoIt
Guest
Posts: n/a
 
      1st May 2009
On May 1, 11:54*am, LetMeDoIt <powercode...@yahoo.com> wrote:
> Greetings,
> I'm trying to do an easy thing (I think) but have not succeeded thus
> far.
>
> I created a name range manually in a spreadsheet, but need to check
> via VBA code for the value of that range, then if it changed to its
> default, reset that range to a specific value.
>
> To check the that the row has not changed, I do the following: iRow =
> Range("=MyRange").Row
> and thus if this is not my original value, I reassigned it ( this is
> where I'm getting an error msg in the code).
>
> Or alternatively, I'd like to dynamically set that range to soemthing specific, like: "sheet1!$B$10:$B$30"
>
> I'm using excel 2003.
>
> Many thanks.
> CG


 
Reply With Quote
 
Jim Thomlinson
Guest
Posts: n/a
 
      1st May 2009
Try
iRow = range("MyRange").row
--
HTH...

Jim Thomlinson


"LetMeDoIt" wrote:

> Greetings,
> I'm trying to do an easy thing (I think) but have not succeeded thus
> far.
>
> I created a name range manually in a spreadsheet, but need to check
> via VBA code for the value of that range, then if it changed to its
> default, reset that range to a specific value.
>
> To check the that the row has not changed, I do the following: iRow =
> Range("=MyRange").Row
> and thus if this is not my original value, I reassigned it ( this is
> where I'm getting an error msg in the code).
>
> I'm using excel 2003.
>
> Many thanks.
> CG
>

 
Reply With Quote
 
LetMeDoIt
Guest
Posts: n/a
 
      1st May 2009
On May 1, 12:12*pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com> wrote:
> Try
> iRow = range("MyRange").row
> --
> HTH...
>
> Jim Thomlinson
>
>
>
> "LetMeDoIt" wrote:
> > Greetings,
> > I'm trying to do an easy thing (I think) but have not succeeded thus
> > far.

>
> > I created a name range manually in a spreadsheet, but need to check
> > via VBA code for the value of that range, then if it changed to its
> > default, reset that range to a specific value.

>
> > To check the that the row has not changed, I do the following: iRow =
> > Range("=MyRange").Row
> > and thus if this is not my original value, I reassigned it ( this is
> > where I'm getting an error msg in the code).

>
> > I'm using excel 2003.

>
> > Many thanks.
> > CG- Hide quoted text -

>
> - Show quoted text -


hhhmmm, but I need to set the range, like something like "sheet1!
B10:B30"
 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      1st May 2009
> hhhmmm, but I need to set the range, like something like
> "sheet1!B10:B30"


Try it this way...

Names("MyRange").RefersTo = "=Sheet1!$B$10:$B$30"

--
Rick (MVP - Excel)


"LetMeDoIt" <(E-Mail Removed)> wrote in message
news:cebd4012-b8d0-441d-9f15-(E-Mail Removed)...
On May 1, 12:12 pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com> wrote:
> Try
> iRow = range("MyRange").row
> --
> HTH...
>
> Jim Thomlinson
>
>
>
> "LetMeDoIt" wrote:
> > Greetings,
> > I'm trying to do an easy thing (I think) but have not succeeded thus
> > far.

>
> > I created a name range manually in a spreadsheet, but need to check
> > via VBA code for the value of that range, then if it changed to its
> > default, reset that range to a specific value.

>
> > To check the that the row has not changed, I do the following: iRow =
> > Range("=MyRange").Row
> > and thus if this is not my original value, I reassigned it ( this is
> > where I'm getting an error msg in the code).

>
> > I'm using excel 2003.

>
> > Many thanks.
> > CG- Hide quoted text -

>
> - Show quoted text -


hhhmmm, but I need to set the range, like something like "sheet1!
B10:B30"

 
Reply With Quote
 
LetMeDoIt
Guest
Posts: n/a
 
      1st May 2009
On May 1, 1:58*pm, "Rick Rothstein"
<rick.newsNO.S...@NO.SPAMverizon.net> wrote:
> > hhhmmm, but I need to set the range, like something like
> > "sheet1!B10:B30"

>
> Try it this way...
>
> Names("MyRange").RefersTo = "=Sheet1!$B$10:$B$30"
>
> --
> Rick (MVP - Excel)
>
> "LetMeDoIt" <powercode...@yahoo.com> wrote in message
>
> news:cebd4012-b8d0-441d-9f15-(E-Mail Removed)...
> On May 1, 12:12 pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
>
>
>
>
>
> This-.com> wrote:
> > Try
> > iRow = range("MyRange").row
> > --
> > HTH...

>
> > Jim Thomlinson

>
> > "LetMeDoIt" wrote:
> > > Greetings,
> > > I'm trying to do an easy thing (I think) but have not succeeded thus
> > > far.

>
> > > I created a name range manually in a spreadsheet, but need to check
> > > via VBA code for the value of that range, then if it changed to its
> > > default, reset that range to a specific value.

>
> > > To check the that the row has not changed, I do the following: iRow =
> > > Range("=MyRange").Row
> > > and thus if this is not my original value, I reassigned it ( this is
> > > where I'm getting an error msg in the code).

>
> > > I'm using excel 2003.

>
> > > Many thanks.
> > > CG- Hide quoted text -

>
> > - Show quoted text -

>
> hhhmmm, but I need to set the range, like something like "sheet1!
> B10:B30"- Hide quoted text -
>
> - Show quoted text -


I'm getting "application-defined or object-defined error". I'm using
office 2003. Can that be an issue?
 
Reply With Quote
 
LetMeDoIt
Guest
Posts: n/a
 
      1st May 2009
On May 1, 1:58*pm, "Rick Rothstein"
<rick.newsNO.S...@NO.SPAMverizon.net> wrote:
> > hhhmmm, but I need to set the range, like something like
> > "sheet1!B10:B30"

>
> Try it this way...
>
> Names("MyRange").RefersTo = "=Sheet1!$B$10:$B$30"
>
> --
> Rick (MVP - Excel)
>
> "LetMeDoIt" <powercode...@yahoo.com> wrote in message
>
> news:cebd4012-b8d0-441d-9f15-(E-Mail Removed)...
> On May 1, 12:12 pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
>
>
>
>
>
> This-.com> wrote:
> > Try
> > iRow = range("MyRange").row
> > --
> > HTH...

>
> > Jim Thomlinson

>
> > "LetMeDoIt" wrote:
> > > Greetings,
> > > I'm trying to do an easy thing (I think) but have not succeeded thus
> > > far.

>
> > > I created a name range manually in a spreadsheet, but need to check
> > > via VBA code for the value of that range, then if it changed to its
> > > default, reset that range to a specific value.

>
> > > To check the that the row has not changed, I do the following: iRow =
> > > Range("=MyRange").Row
> > > and thus if this is not my original value, I reassigned it ( this is
> > > where I'm getting an error msg in the code).

>
> > > I'm using excel 2003.

>
> > > Many thanks.
> > > CG- Hide quoted text -

>
> > - Show quoted text -

>
> hhhmmm, but I need to set the range, like something like "sheet1!
> B10:B30"- Hide quoted text -
>
> - Show quoted text -


never mind... i added application. in front of your statement, and
it's working like a charm. Many thanks for your help.

CG
 
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
Checking range of cells for entry then checking for total =?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?= Microsoft Excel Programming 1 13th Oct 2006 02:47 PM
Checking if a cell value in one range is contained in a second range? ModelerGirl Microsoft Excel Discussion 4 21st Feb 2006 03:16 PM
Re: setting range().hidden=True causes range error 1004 Tom Ogilvy Microsoft Excel Programming 0 1st Sep 2005 09:11 PM
Re: setting range().hidden=True causes range error 1004 Tom Ogilvy Microsoft Excel Programming 0 1st Sep 2005 09:06 PM
Setting Source Data to a Named Range rather than cell Range Justin Smith Microsoft Excel Charting 2 5th Dec 2003 05:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:15 PM.