Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Can't pass publically defined variable to a function

I have a variable called "cell" which I have dimensioned as a Range. I also
have a function called AdjustForUniqueFormula. When I pass this public
variable to the funtion

AdjustForUniqueFormula(cell)

I get a Run Time Error 13 Type Mismatch. Why is this?

If AdjustForUniqueFormula(cell) = True Then
Exit Sub
Else
'Do Something........
End if

Public Function AdjustForUniqueFormula()

If UniqueFormulasAdjustChkBx = True Then
If Not IsError(Application.WorksheetFunction.Match(cell.P arent.Name &
"!" & cell.Address, UniqueCellAddressArray3, 0) - 1) Then
AdjustForUniqueFormula = False
Else
AdjustForUniqueFormula = True
End If
Else
AdjustForUniqueFormula = False
End If
End Function


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Can't pass publically defined variable to a function


Your AdjustForUniqueFormula function isn't defined to take any
arguments, so you can't pass it any. If your cell variable is truly public
you don't need to pass it to the function at all, the function will be able
to "see" it because it's public.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm

"ExcelMonkey" wrote in message
...
I have a variable called "cell" which I have dimensioned as a Range. I
also
have a function called AdjustForUniqueFormula. When I pass this public
variable to the funtion

AdjustForUniqueFormula(cell)

I get a Run Time Error 13 Type Mismatch. Why is this?

If AdjustForUniqueFormula(cell) = True Then
Exit Sub
Else
'Do Something........
End if

Public Function AdjustForUniqueFormula()

If UniqueFormulasAdjustChkBx = True Then
If Not IsError(Application.WorksheetFunction.Match(cell.P arent.Name &
"!" & cell.Address, UniqueCellAddressArray3, 0) - 1) Then
AdjustForUniqueFormula = False
Else
AdjustForUniqueFormula = True
End If
Else
AdjustForUniqueFormula = False
End If
End Function




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Can't pass publically defined variable to a function

You have a guess at your other post.

ExcelMonkey wrote:

I have a variable called "cell" which I have dimensioned as a Range. I also
have a function called AdjustForUniqueFormula. When I pass this public
variable to the funtion

AdjustForUniqueFormula(cell)

I get a Run Time Error 13 Type Mismatch. Why is this?

If AdjustForUniqueFormula(cell) = True Then
Exit Sub
Else
'Do Something........
End if

Public Function AdjustForUniqueFormula()

If UniqueFormulasAdjustChkBx = True Then
If Not IsError(Application.WorksheetFunction.Match(cell.P arent.Name &
"!" & cell.Address, UniqueCellAddressArray3, 0) - 1) Then
AdjustForUniqueFormula = False
Else
AdjustForUniqueFormula = True
End If
Else
AdjustForUniqueFormula = False
End If
End Function


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Can't pass publically defined variable to a function

I don't see where you have declared cell. One thing to check is that in your
function header, you don't list any input parameters but rely on the public
nature of the variable. However you do supply an input parameter when you
call the function.

Perhaps this is confusing Excel.
--
Gary's Student


"ExcelMonkey" wrote:

I have a variable called "cell" which I have dimensioned as a Range. I also
have a function called AdjustForUniqueFormula. When I pass this public
variable to the funtion

AdjustForUniqueFormula(cell)

I get a Run Time Error 13 Type Mismatch. Why is this?

If AdjustForUniqueFormula(cell) = True Then
Exit Sub
Else
'Do Something........
End if

Public Function AdjustForUniqueFormula()

If UniqueFormulasAdjustChkBx = True Then
If Not IsError(Application.WorksheetFunction.Match(cell.P arent.Name &
"!" & cell.Address, UniqueCellAddressArray3, 0) - 1) Then
AdjustForUniqueFormula = False
Else
AdjustForUniqueFormula = True
End If
Else
AdjustForUniqueFormula = False
End If
End Function


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
Pass variable to NORMINSV function to get only mean value ExcelMonkey Excel Worksheet Functions 3 June 19th 06 06:01 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Pass a Variable List Of Values To Subroutine or Function Dean Hinson[_3_] Excel Programming 2 January 28th 05 06:49 PM
Pass Variable Question SyrHoop Excel Programming 2 November 10th 04 05:15 PM
publically defined command bar variable problem Joe Excel Programming 1 March 5th 04 02:22 PM


All times are GMT +1. The time now is 07:55 AM.

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"