Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default checking and setting a value to a range in VBA

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default checking and setting a value to a range in VBA

On May 1, 11:54*am, 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).

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default checking and setting a value to a range in VBA

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default checking and setting a value to a range in VBA

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"
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default checking and setting a value to a range in VBA

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default checking and setting a value to a range in VBA

On May 1, 1:58*pm, "Rick Rothstein"
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" wrote in message

...
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?
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default checking and setting a value to a range in VBA

On May 1, 1:58*pm, "Rick Rothstein"
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" wrote in message

...
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
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
checking a range for at least one Theo Excel Programming 2 January 24th 08 12:53 AM
Checking a range with IF Rob J Excel Discussion (Misc queries) 4 October 18th 06 05:44 PM
Checking range of cells for entry then checking for total Barb Reinhardt Excel Programming 1 October 13th 06 02:47 PM
Checking/Setting a reference on open RWN Excel Programming 2 November 24th 05 04:41 AM
checking if a range has a name. Peter[_21_] Excel Programming 1 November 10th 04 01:05 AM


All times are GMT +1. The time now is 05:55 PM.

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"