Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Dim problems

What is the problem with the following ?

Dim r As Integer
Dim s As String

r = Application.Count(Sheet1.Range("Set_Size_Range"))
s = ActiveWorkbook.Names("Set_Size").RefersTo

If r = s Then



When the IF line executes, a "Run-time error '13': Type mismatch" error
occurs.

The following are the debug.print outputs

r equals 126

s equals =ABS(MIN(Data_Header_Row))

If you type =Set_Size in a cell, the value returned is 126.

What is the syntax for assigning the value of the name "Set_Size" to the
variable s ?



kittronald


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Dim problems

On Feb 24, 5:05*pm, "kittronald" wrote:
* * What is the problem with the following ?

* * * * Dim r As Integer
* * * * Dim s As String

* * * * r = Application.Count(Sheet1.Range("Set_Size_Range"))
* * * * s = ActiveWorkbook.Names("Set_Size").RefersTo

* * * * If r = s Then

* * When the IF line executes, a "Run-time error '13': Type mismatch" error
occurs.

* * The following are the debug.print outputs

* * * * r equals *126

* * * * s equals =ABS(MIN(Data_Header_Row))

* * If you type =Set_Size in a cell, the value returned is 126.

* * What is the syntax for assigning the value of the name "Set_Size" to the
variable s ?

kittronald


You may benefit from using
msgbox r
msgbox s
for testing

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Dim problems

Don,

Thanks for the quick reply.

I did that and got the same results as the debug.print.

I can see that variable r is returning a number and variable s is
returning the formula (string) in the Refers to: field of the name.

How can I get the variable s to evaluate to the value of the name
"Set_Size" which is the number 126.


kittronald


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Dim problems


s = ActiveWorkbook.Names("Set_Size").RefersTo
MsgBox Application.Evaluate(s)

Tim

On Feb 24, 3:23*pm, "kittronald" wrote:
Don,

* * Thanks for the quick reply.

* * I did that and got the same results as the debug.print.

* * I can see that variable r is returning a number and variable s is
returning the formula (string) in the Refers to: field of the name.

* * How can I get the variable s to evaluate to the value of the name
"Set_Size" which is the number 126.

kittronald


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Dim problems

Tim,

Thanks for the response.

What I'm trying to do is get the variable s to equal the value that is
returned by the defined name "Set_Size".

The problem is the variable r is an integer and the Refers to: field of
the defined name "Set_Size" contains a formula (which makes it a string
value).

A type mismatch occurs because the IF statement is comparing two
different data types.

What's the best way to get the variable s to equal the integer value of
the "Set_Size" name ?


kittronald




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Dim problems

kittronald brought next idea :
Tim,

Thanks for the response.

What I'm trying to do is get the variable s to equal the value that is
returned by the defined name "Set_Size".

The problem is the variable r is an integer and the Refers to: field of
the defined name "Set_Size" contains a formula (which makes it a string
value).

A type mismatch occurs because the IF statement is comparing two
different data types.

What's the best way to get the variable s to equal the integer value of
the "Set_Size" name ?


kittronald


Use a Variant data type to retrieve the value stored in the defined
name, with the Evaluate() function.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


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
aauugghhh...#div/o problems & various average formula problems acbel40 Excel Worksheet Functions 5 October 19th 09 05:00 PM
VBA problems [email protected] Excel Programming 0 August 28th 06 10:20 PM
SP3 problems Ron Weaver Excel Discussion (Misc queries) 3 March 19th 05 04:57 PM
Problems merging an excel file due to code or file problems? Cindy M -WordMVP- Excel Programming 0 September 14th 04 02:58 PM
PS to PDF Problems Jmbostock[_16_] Excel Programming 0 July 24th 04 12:41 AM


All times are GMT +1. The time now is 03:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"