PC Review


Reply
Thread Tools Rate Thread

checking value of named range

 
 
mark kubicki
Guest
Posts: n/a
 
      31st Oct 2006
even though the value for [ReformatingCompleted] seems to have been set to
"True", I'm not able to test for it correctly;
could someone proof this short code for me? (it's prob an obvious mistake...
u know how that goes...)

--------------------
ActiveWorkbook.ActiveSheet.Names.Add Name:="ReformatingCompleted",
RefersToR1C1:="=""True"""


If ActiveWorkbook.ActiveSheet.Names("ReformatingCompleted").Value = "True"
Then
Exit Sub
End If
--------------------


thanks in advance,
mark


 
Reply With Quote
 
 
 
 
bobbo
Guest
Posts: n/a
 
      31st Oct 2006
After "RefesToR1C1:= " you need something that refers to a range in
R1C1 format.
Then to set it to true
Activeworkbok.Names("ReformatingCompleted").RefersToRange.Value =
"True"

mark kubicki wrote:
> even though the value for [ReformatingCompleted] seems to have been set to
> "True", I'm not able to test for it correctly;
> could someone proof this short code for me? (it's prob an obvious mistake...
> u know how that goes...)
>
> --------------------
> ActiveWorkbook.ActiveSheet.Names.Add Name:="ReformatingCompleted",
> RefersToR1C1:="=""True"""
>
>
> If ActiveWorkbook.ActiveSheet.Names("ReformatingCompleted").Value = "True"
> Then
> Exit Sub
> End If
> --------------------
>
>
> thanks in advance,
> mark


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      31st Oct 2006
This did work ok for me:

ActiveWorkbook.ActiveSheet.Names.Add _
Name:="ReformatingCompleted", RefersToR1C1:=True

If ActiveWorkbook.ActiveSheet.Names("ReformatingCompleted").Value = "=TRUE" Then
MsgBox "hi"
Else
MsgBox "bye"
End If

mark kubicki wrote:
>
> even though the value for [ReformatingCompleted] seems to have been set to
> "True", I'm not able to test for it correctly;
> could someone proof this short code for me? (it's prob an obvious mistake...
> u know how that goes...)
>
> --------------------
> ActiveWorkbook.ActiveSheet.Names.Add Name:="ReformatingCompleted",
> RefersToR1C1:="=""True"""
>
> If ActiveWorkbook.ActiveSheet.Names("ReformatingCompleted").Value = "True"
> Then
> Exit Sub
> End If
> --------------------
>
> thanks in advance,
> mark


--

Dave Peterson
 
Reply With Quote
 
mark kubicki
Guest
Posts: n/a
 
      31st Oct 2006
o.k.

I kind of get it... (I immediately get lost in R1C1 world) but...
I'm not sure,

am I editing the code where is the value to true
or,
editing the code where I check if the value is true?

and, in either case (excuse my dumbness), could you spell out what the exact
code ought to be

-mark

-------------------------------------------------------------------------------------------------


"bobbo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> After "RefesToR1C1:= " you need something that refers to a range in
> R1C1 format.
> Then to set it to true
> Activeworkbok.Names("ReformatingCompleted").RefersToRange.Value =
> "True"
>
> mark kubicki wrote:
>> even though the value for [ReformatingCompleted] seems to have been set
>> to
>> "True", I'm not able to test for it correctly;
>> could someone proof this short code for me? (it's prob an obvious
>> mistake...
>> u know how that goes...)
>>
>> --------------------
>> ActiveWorkbook.ActiveSheet.Names.Add Name:="ReformatingCompleted",
>> RefersToR1C1:="=""True"""
>>
>>
>> If ActiveWorkbook.ActiveSheet.Names("ReformatingCompleted").Value =
>> "True"
>> Then
>> Exit Sub
>> End If
>> --------------------
>>
>>
>> thanks in advance,
>> mark

>



 
Reply With Quote
 
bobbo
Guest
Posts: n/a
 
      31st Oct 2006
Dave has more expertise than I do. He helped me write my first UDF. You
might want to try his code if it accomplishes your task. As R1C1
notation it is just a different way of writing ranges where both the
row and column have a number. Here is the code that I wrote to test
it.

Sub Tst()
ActiveWorkbook.ActiveSheet.Names.Add _
name:="ReformatingCompleted", RefersToR1C1:="=Sheet1!R4C2:R9C2"
' this is Sheet1 range B4:B9 named ReformatingCompleted

ActiveWorkbook.Names("ReformatingCompleted").RefersToRange.Value = 4
' this gives range B4:B9 a value of 4

End Sub

To use Dave's code I think just copy and paste this

ActiveWorkbook.ActiveSheet.Names.Add _
Name:="ReformatingCompleted", RefersToR1C1:=True


If ActiveWorkbook.ActiveSheet.Names("ReformatingCompleted").Value =
"=TRUE" Then
exit sub
end if

My code creates a workbook level name that denotes a range. Dave's
creates a worksheet level name. I can not really eloborate on the finer
differences because honestly I do not know. Figure out which one works
the best for your purpose and use that. My code will actually make a
range that has a value of True displayed in it.



mark kubicki wrote:
> o.k.
>
> I kind of get it... (I immediately get lost in R1C1 world) but...
> I'm not sure,
>
> am I editing the code where is the value to true
> or,
> editing the code where I check if the value is true?
>
> and, in either case (excuse my dumbness), could you spell out what the exact
> code ought to be
>
> -mark
>
> -------------------------------------------------------------------------------------------------
>
>
> "bobbo" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > After "RefesToR1C1:= " you need something that refers to a range in
> > R1C1 format.
> > Then to set it to true
> > Activeworkbok.Names("ReformatingCompleted").RefersToRange.Value =
> > "True"
> >
> > mark kubicki wrote:
> >> even though the value for [ReformatingCompleted] seems to have been set
> >> to
> >> "True", I'm not able to test for it correctly;
> >> could someone proof this short code for me? (it's prob an obvious
> >> mistake...
> >> u know how that goes...)
> >>
> >> --------------------
> >> ActiveWorkbook.ActiveSheet.Names.Add Name:="ReformatingCompleted",
> >> RefersToR1C1:="=""True"""
> >>
> >>
> >> If ActiveWorkbook.ActiveSheet.Names("ReformatingCompleted").Value =
> >> "True"
> >> Then
> >> Exit Sub
> >> End If
> >> --------------------
> >>
> >>
> >> thanks in advance,
> >> mark

> >


 
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 a cell against a named range =?Utf-8?B?TWVtZW50bw==?= Microsoft Excel Worksheet Functions 8 7th Apr 2007 01:46 PM
Checking named range learner Microsoft Excel Discussion 4 11th Nov 2006 02:30 AM
Checking for non-blank cells in named range =?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?= Microsoft Excel Programming 2 13th Oct 2006 06:34 PM
Checking for non blank cells in named range =?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?= Microsoft Excel Programming 1 13th Oct 2006 03:32 PM
Checking for non-blank cells in named range =?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?= Microsoft Excel Programming 0 13th Oct 2006 02:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:56 AM.