Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default How does this function works?

Hi Guys!
Can anyone help me how does this one works and how to use this function?
Thanks,
Jay


Function VTest(ByRef AMsg As String, ByRef AMsW As Double, ByRef AMsX As
Integer, _
ByRef AMsY As Integer, ByRef AMsZ As Integer, ByRef AMsH As Integer,
ByRef AMsT As Variant)
'Verify ActiveCell and ActiveSheet Selection
'Used by Procedures - Months, Distribute, & Produce
Dim Tmp As Variant, Tmi As Integer

VTest = WWks()
If VTest Then Exit Function
AMsP = AMsk
If IsNumeric(Expression:=ActiveCell.Value) Then
AMsW = ActiveCell.Value
If IsNumeric(AMsW) Then
GoTo Rtest
Else
GoTo Erxis
End If
Else
GoTo Erxis
End If

Erxis:
AMsD = AMsP & AMsg & Chr(13) & Chr(10) & Chr(13) & Chr(10) & AMsc
Beep
Beep
Tmp = vbOKOnly + vbCritical
ARep = MsgBox(prompt:=AMsD, Buttons:=Tmp, Title:=" SELECTION ERROR")
Erxi2:
VTest = True
Exit Function

Rtest:
If ActiveCell.Row = 17 Then GoTo Erxi2
AMsX = ActiveCell.Column
AMsY = ActiveCell.Row
AMsH = 0
If AMsg = MSP Then
Tmp = Application.Lookup(AMsX, vrEITab)
If Tmp < AMsX Then GoTo Erxis
If AMsX = 5 Then
VTest = False
Exit Function
End If
End If
AMsP = AMso
AMsH = Int((AMsX - AMsZ) / 4)
If AMsX < AMsZ Or AMsX Range("MaxReqCol").Value Then GoTo Erxis
Tmp = Application.Lookup(AMsY, AMsT)
' If Tmp < AMsY Then GoTo Erxis
VTest = False
End Function 'Vtest
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default How does this function works?

Use it for what ?
It's clearly only a small part of something bigger (and that is some odd
coding style....) - what part is giving you a problem?

Tim

"Jay" wrote in message
...
Hi Guys!
Can anyone help me how does this one works and how to use this function?
Thanks,
Jay


Function VTest(ByRef AMsg As String, ByRef AMsW As Double, ByRef AMsX As
Integer, _
ByRef AMsY As Integer, ByRef AMsZ As Integer, ByRef AMsH As Integer,
ByRef AMsT As Variant)
'Verify ActiveCell and ActiveSheet Selection
'Used by Procedures - Months, Distribute, & Produce
Dim Tmp As Variant, Tmi As Integer

VTest = WWks()
If VTest Then Exit Function
AMsP = AMsk
If IsNumeric(Expression:=ActiveCell.Value) Then
AMsW = ActiveCell.Value
If IsNumeric(AMsW) Then
GoTo Rtest
Else
GoTo Erxis
End If
Else
GoTo Erxis
End If

Erxis:
AMsD = AMsP & AMsg & Chr(13) & Chr(10) & Chr(13) & Chr(10) & AMsc
Beep
Beep
Tmp = vbOKOnly + vbCritical
ARep = MsgBox(prompt:=AMsD, Buttons:=Tmp, Title:=" SELECTION ERROR")
Erxi2:
VTest = True
Exit Function

Rtest:
If ActiveCell.Row = 17 Then GoTo Erxi2
AMsX = ActiveCell.Column
AMsY = ActiveCell.Row
AMsH = 0
If AMsg = MSP Then
Tmp = Application.Lookup(AMsX, vrEITab)
If Tmp < AMsX Then GoTo Erxis
If AMsX = 5 Then
VTest = False
Exit Function
End If
End If
AMsP = AMso
AMsH = Int((AMsX - AMsZ) / 4)
If AMsX < AMsZ Or AMsX Range("MaxReqCol").Value Then GoTo Erxis
Tmp = Application.Lookup(AMsY, AMsT)
' If Tmp < AMsY Then GoTo Erxis
VTest = False
End Function 'Vtest



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default How does this function works?

I am disappointed with you Tim.

Given a piece of badly written code with absolutely no context, you fail to
understand what it does, how it does it, and how to use it.

--
__________________________________
HTH

Bob

"Tim Williams" <timjwilliams at gmail dot com wrote in message
...
Use it for what ?
It's clearly only a small part of something bigger (and that is some odd
coding style....) - what part is giving you a problem?

Tim

"Jay" wrote in message
...
Hi Guys!
Can anyone help me how does this one works and how to use this function?
Thanks,
Jay


Function VTest(ByRef AMsg As String, ByRef AMsW As Double, ByRef AMsX As
Integer, _
ByRef AMsY As Integer, ByRef AMsZ As Integer, ByRef AMsH As Integer,
ByRef AMsT As Variant)
'Verify ActiveCell and ActiveSheet Selection
'Used by Procedures - Months, Distribute, & Produce
Dim Tmp As Variant, Tmi As Integer

VTest = WWks()
If VTest Then Exit Function
AMsP = AMsk
If IsNumeric(Expression:=ActiveCell.Value) Then
AMsW = ActiveCell.Value
If IsNumeric(AMsW) Then
GoTo Rtest
Else
GoTo Erxis
End If
Else
GoTo Erxis
End If

Erxis:
AMsD = AMsP & AMsg & Chr(13) & Chr(10) & Chr(13) & Chr(10) & AMsc
Beep
Beep
Tmp = vbOKOnly + vbCritical
ARep = MsgBox(prompt:=AMsD, Buttons:=Tmp, Title:=" SELECTION ERROR")
Erxi2:
VTest = True
Exit Function

Rtest:
If ActiveCell.Row = 17 Then GoTo Erxi2
AMsX = ActiveCell.Column
AMsY = ActiveCell.Row
AMsH = 0
If AMsg = MSP Then
Tmp = Application.Lookup(AMsX, vrEITab)
If Tmp < AMsX Then GoTo Erxis
If AMsX = 5 Then
VTest = False
Exit Function
End If
End If
AMsP = AMso
AMsH = Int((AMsX - AMsZ) / 4)
If AMsX < AMsZ Or AMsX Range("MaxReqCol").Value Then GoTo Erxis
Tmp = Application.Lookup(AMsY, AMsT)
' If Tmp < AMsY Then GoTo Erxis
VTest = False
End Function 'Vtest





  #4   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default How does this function works?

Guys, I'd just like to know how does a function works using the code below as
an example coz it is difficult to show its result without any context. So
here's specifically is the thing I wanna know:

- if you use this function to other procedures and declare a variable in it,
does these byref variable be computed first in this function before being
used by other procedure?

Thanks for the help.
jay

"Bob Phillips" wrote:

I am disappointed with you Tim.

Given a piece of badly written code with absolutely no context, you fail to
understand what it does, how it does it, and how to use it.

--
__________________________________
HTH

Bob

"Tim Williams" <timjwilliams at gmail dot com wrote in message
...
Use it for what ?
It's clearly only a small part of something bigger (and that is some odd
coding style....) - what part is giving you a problem?

Tim

"Jay" wrote in message
...
Hi Guys!
Can anyone help me how does this one works and how to use this function?
Thanks,
Jay


Function VTest(ByRef AMsg As String, ByRef AMsW As Double, ByRef AMsX As
Integer, _
ByRef AMsY As Integer, ByRef AMsZ As Integer, ByRef AMsH As Integer,
ByRef AMsT As Variant)
'Verify ActiveCell and ActiveSheet Selection
'Used by Procedures - Months, Distribute, & Produce
Dim Tmp As Variant, Tmi As Integer

VTest = WWks()
If VTest Then Exit Function
AMsP = AMsk
If IsNumeric(Expression:=ActiveCell.Value) Then
AMsW = ActiveCell.Value
If IsNumeric(AMsW) Then
GoTo Rtest
Else
GoTo Erxis
End If
Else
GoTo Erxis
End If

Erxis:
AMsD = AMsP & AMsg & Chr(13) & Chr(10) & Chr(13) & Chr(10) & AMsc
Beep
Beep
Tmp = vbOKOnly + vbCritical
ARep = MsgBox(prompt:=AMsD, Buttons:=Tmp, Title:=" SELECTION ERROR")
Erxi2:
VTest = True
Exit Function

Rtest:
If ActiveCell.Row = 17 Then GoTo Erxi2
AMsX = ActiveCell.Column
AMsY = ActiveCell.Row
AMsH = 0
If AMsg = MSP Then
Tmp = Application.Lookup(AMsX, vrEITab)
If Tmp < AMsX Then GoTo Erxis
If AMsX = 5 Then
VTest = False
Exit Function
End If
End If
AMsP = AMso
AMsH = Int((AMsX - AMsZ) / 4)
If AMsX < AMsZ Or AMsX Range("MaxReqCol").Value Then GoTo Erxis
Tmp = Application.Lookup(AMsY, AMsT)
' If Tmp < AMsY Then GoTo Erxis
VTest = False
End Function 'Vtest






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default How does this function works?

Let me re-phrase Bob's light hearted comment and direct it to you.

The code is badly written. As posted it has is no context. It is not
possible for anyone to understand what it is supposed to do, how it does it,
or how to use it. At least not without a lot of effort, second guessing
what's intended and correcting it.

If you are looking at it only as a learning exercise it serves no useful
purpose.

Concerning ByRef, all is explained in VBA Help. Following should show the
difference between ByRef and ByVal

Sub test()
Dim apple As Long, pear As Long, vResult

apple = 3: pear = 5

vResult = foo(apple, pear)

Debug.Print vResult, apple; pear ' 16, 6 5
' notice ByRef apple returns changed but ByVal pear is unchanged

End Sub

Function foo(ByRef a As Long, ByVal b As Long)

a = a * 2
b = b * 2
foo = a + b
End Function

Regards,
Peter T

"Jay" wrote in message
...
Guys, I'd just like to know how does a function works using the code below
as
an example coz it is difficult to show its result without any context. So
here's specifically is the thing I wanna know:

- if you use this function to other procedures and declare a variable in
it,
does these byref variable be computed first in this function before being
used by other procedure?

Thanks for the help.
jay

"Bob Phillips" wrote:

I am disappointed with you Tim.

Given a piece of badly written code with absolutely no context, you fail
to
understand what it does, how it does it, and how to use it.

--
__________________________________
HTH

Bob

"Tim Williams" <timjwilliams at gmail dot com wrote in message
...
Use it for what ?
It's clearly only a small part of something bigger (and that is some
odd
coding style....) - what part is giving you a problem?

Tim

"Jay" wrote in message
...
Hi Guys!
Can anyone help me how does this one works and how to use this
function?
Thanks,
Jay


Function VTest(ByRef AMsg As String, ByRef AMsW As Double, ByRef AMsX
As
Integer, _
ByRef AMsY As Integer, ByRef AMsZ As Integer, ByRef AMsH As
Integer,
ByRef AMsT As Variant)
'Verify ActiveCell and ActiveSheet Selection
'Used by Procedures - Months, Distribute, & Produce
Dim Tmp As Variant, Tmi As Integer

VTest = WWks()
If VTest Then Exit Function
AMsP = AMsk
If IsNumeric(Expression:=ActiveCell.Value) Then
AMsW = ActiveCell.Value
If IsNumeric(AMsW) Then
GoTo Rtest
Else
GoTo Erxis
End If
Else
GoTo Erxis
End If

Erxis:
AMsD = AMsP & AMsg & Chr(13) & Chr(10) & Chr(13) & Chr(10) & AMsc
Beep
Beep
Tmp = vbOKOnly + vbCritical
ARep = MsgBox(prompt:=AMsD, Buttons:=Tmp, Title:=" SELECTION
ERROR")
Erxi2:
VTest = True
Exit Function

Rtest:
If ActiveCell.Row = 17 Then GoTo Erxi2
AMsX = ActiveCell.Column
AMsY = ActiveCell.Row
AMsH = 0
If AMsg = MSP Then
Tmp = Application.Lookup(AMsX, vrEITab)
If Tmp < AMsX Then GoTo Erxis
If AMsX = 5 Then
VTest = False
Exit Function
End If
End If
AMsP = AMso
AMsH = Int((AMsX - AMsZ) / 4)
If AMsX < AMsZ Or AMsX Range("MaxReqCol").Value Then GoTo Erxis
Tmp = Application.Lookup(AMsY, AMsT)
' If Tmp < AMsY Then GoTo Erxis
VTest = False
End Function 'Vtest









  #6   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default How does this function works?

Thanks Peter thats all I need to know. Anyway that code was'nt my work Im
trying to understand how and why he does that.

Thanks you and regards,
Jay

"Peter T" wrote:

Let me re-phrase Bob's light hearted comment and direct it to you.

The code is badly written. As posted it has is no context. It is not
possible for anyone to understand what it is supposed to do, how it does it,
or how to use it. At least not without a lot of effort, second guessing
what's intended and correcting it.

If you are looking at it only as a learning exercise it serves no useful
purpose.

Concerning ByRef, all is explained in VBA Help. Following should show the
difference between ByRef and ByVal

Sub test()
Dim apple As Long, pear As Long, vResult

apple = 3: pear = 5

vResult = foo(apple, pear)

Debug.Print vResult, apple; pear ' 16, 6 5
' notice ByRef apple returns changed but ByVal pear is unchanged

End Sub

Function foo(ByRef a As Long, ByVal b As Long)

a = a * 2
b = b * 2
foo = a + b
End Function

Regards,
Peter T

"Jay" wrote in message
...
Guys, I'd just like to know how does a function works using the code below
as
an example coz it is difficult to show its result without any context. So
here's specifically is the thing I wanna know:

- if you use this function to other procedures and declare a variable in
it,
does these byref variable be computed first in this function before being
used by other procedure?

Thanks for the help.
jay

"Bob Phillips" wrote:

I am disappointed with you Tim.

Given a piece of badly written code with absolutely no context, you fail
to
understand what it does, how it does it, and how to use it.

--
__________________________________
HTH

Bob

"Tim Williams" <timjwilliams at gmail dot com wrote in message
...
Use it for what ?
It's clearly only a small part of something bigger (and that is some
odd
coding style....) - what part is giving you a problem?

Tim

"Jay" wrote in message
...
Hi Guys!
Can anyone help me how does this one works and how to use this
function?
Thanks,
Jay


Function VTest(ByRef AMsg As String, ByRef AMsW As Double, ByRef AMsX
As
Integer, _
ByRef AMsY As Integer, ByRef AMsZ As Integer, ByRef AMsH As
Integer,
ByRef AMsT As Variant)
'Verify ActiveCell and ActiveSheet Selection
'Used by Procedures - Months, Distribute, & Produce
Dim Tmp As Variant, Tmi As Integer

VTest = WWks()
If VTest Then Exit Function
AMsP = AMsk
If IsNumeric(Expression:=ActiveCell.Value) Then
AMsW = ActiveCell.Value
If IsNumeric(AMsW) Then
GoTo Rtest
Else
GoTo Erxis
End If
Else
GoTo Erxis
End If

Erxis:
AMsD = AMsP & AMsg & Chr(13) & Chr(10) & Chr(13) & Chr(10) & AMsc
Beep
Beep
Tmp = vbOKOnly + vbCritical
ARep = MsgBox(prompt:=AMsD, Buttons:=Tmp, Title:=" SELECTION
ERROR")
Erxi2:
VTest = True
Exit Function

Rtest:
If ActiveCell.Row = 17 Then GoTo Erxi2
AMsX = ActiveCell.Column
AMsY = ActiveCell.Row
AMsH = 0
If AMsg = MSP Then
Tmp = Application.Lookup(AMsX, vrEITab)
If Tmp < AMsX Then GoTo Erxis
If AMsX = 5 Then
VTest = False
Exit Function
End If
End If
AMsP = AMso
AMsH = Int((AMsX - AMsZ) / 4)
If AMsX < AMsZ Or AMsX Range("MaxReqCol").Value Then GoTo Erxis
Tmp = Application.Lookup(AMsY, AMsT)
' If Tmp < AMsY Then GoTo Erxis
VTest = False
End Function 'Vtest








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
function works on some sheets but not others danafeldman Excel Worksheet Functions 4 October 13th 08 07:30 PM
Function works in one cell but not another myssieh Excel Worksheet Functions 2 September 3rd 08 08:34 PM
Shell function sometimes works, sometimes doesn't HC Hamaker[_2_] Excel Programming 5 June 11th 07 09:02 PM
Can someone test this IF function for me, I'm not sure that it works. dd Excel Worksheet Functions 3 February 22nd 07 08:55 AM
SMALL FUNCTION - How it works [email protected] Excel Discussion (Misc queries) 6 February 13th 07 09:23 AM


All times are GMT +1. The time now is 12:57 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"