Need a book? Engineering books recommendations...

Return to index: [Subject] [Thread] [Date] [Author]

RE: Excel equations *was Calculation Software

[Subject Prev][Subject Next][Thread Prev][Thread Next]
Mark,

Below are the codes I worked up to simulate the disfor.xls function.  I did
not check all possible scenario, so can't say it will work all the time.  In
fact I know the function fails if you refer to another workbook.  Copy and
paste the following code to your visual basic module.  =DispFor() works like
disfor.xls, =DispEqn() display the equation in the referenced cell.

Regards,

Frank

------------Begin Code--------------

Option Explicit

Private Function checkOptr(a As String) As Boolean
    Dim optr As String
    
    optr = "+-*/%^=><&:,()"
    If InStr(optr, a) Then
        checkOptr = True
    Else
        checkOptr = False
    End If
End Function

Function DispFor(a As Range) As String
    Dim optr As Integer
    Dim dataFor As String
    Dim dataStack As String
    Dim ichar As String
    Dim i As Integer
    Dim forLen As Integer
    
    dataFor = a.Formula
    forLen = Len(dataFor)
    For i = 1 To forLen
        ichar = Mid(dataFor, i, 1)
        If checkOptr(ichar) Then
            If ichar = "(" Then
                DispFor = DispFor + dataStack + ichar
                dataStack = ""
            Else
                If Len(dataStack) <> 0 Then
                    If IsNumeric(dataStack) Then
                        DispFor = DispFor + dataStack + ichar
                    Else
                        If InStr(dataStack, "!") Then
                            DispFor = DispFor +
CStr(a.Parent.Parent.Worksheets(Left(dataStack, InStr(dataStack, "!") -
1)).Range(Mid(dataStack, InStr(dataStack, "!") + 1)).Value) + ichar
                        Else
                            DispFor = DispFor +
CStr(a.Parent.Range(dataStack).Value) + ichar
                        End If
                    End If
                    dataStack = ""
                Else
                    DispFor = DispFor + ichar
                End If
            End If
        Else
            If ichar = "'" Then
                i = i + 1
                ichar = Mid(dataFor, i, 1)
                While ichar <> "'"
                    dataStack = dataStack + ichar
                    i = i + 1
                    ichar = Mid(dataFor, i, 1)
                Wend
            Else
                dataStack = dataStack + ichar
            End If
        End If
    Next
    If Len(dataStack) <> 0 Then
        If IsNumeric(dataStack) Then
            DispFor = DispFor + dataStack + ichar
        Else
            If InStr(dataStack, "!") Then
                DispFor = DispFor +
CStr(a.Parent.Parent.Worksheets(Left(dataStack, InStr(dataStack, "!") -
1)).Range(Mid(dataStack, InStr(dataStack, "!") + 1)).Value)
            Else
                DispFor = DispFor + CStr(a.Parent.Range(dataStack).Value)
            End If
        End If
        dataStack = ""
    Else
        DispFor = DispFor
    End If
End Function

Function dispEqn(a As Range) As String
    dispEqn = a.Formula
End Function

----------------End Code------------------ 


Frank Yang, P.E.
Project Engineer                      BERGER/ABAM Engineers Inc
Voice: 206-431-2374                  33301 9th Ave S, Suite 300
Fax:   206-431-2250                 Federal Way, WA  98003-2600
yang(--nospam--at)abam.com                               http://www.abam.com 

Notice: This message (including any attachments) contains confidential 
        information intended for a specific individual and purpose, 
        and is protected by law.  If you are not the intended 
        recipient, you should delete this message, and any disclosure, 
        copying, or distribution of this message, or the taking of any 
        action based upon it, is prohibited.
 

-----Original Message-----
From: Markajohn(--nospam--at)cs.com [mailto:Markajohn(--nospam--at)cs.com] 
Sent: Monday, August 02, 2004 8:06 PM
To: seaint(--nospam--at)seaint.org
Subject: Re: Excel equations *was Calculation Software

Kevin,

Thanks for your e-mail.  I waved the disfor.xls as disfor.xla to my addins
folder, then browsed for it from the Excel, Tools, Addins and got it in the
list and checked it.  It works in files which is great, however, now, each
time I load Excel, his little pop-up comes up (to give me his address and to
ask for money).  That's an improvement.  Maybe the best that can be had is
to uncheck it until I need it.

I even sent a check for $30 to him in hope he would email back a
unprotected, more usable copy, but so far, no such luck.

Thanks Again,
Mark



> Subj:  RE: Excel equations *was Calculation Software
>  Date:    8/2/04 6:32:41 PM Pacific Daylight Time
>  From:    kevinbelow(--nospam--at)videotron.ca (Kevin Below)
>  Reply-to:    seaint(--nospam--at)seaint.org
>  To:  seaint(--nospam--at)seaint.org
>  
>  Mark,
>  I think the procedure is something like this:
>  Save the disfor.xla file in the Addins folder (something like  
> C:/Documents and settings/UserName/Application Data/Microsoft/Addins),  
> then in Excel, go to Tools, Addins, and make sure it is in the list 
> (if  not, Browse for it), then check it. It will be available in all
files.
>  
>  Kevin Below, ing., Ph.D.
>  GÉNÉCOR CIVIL INC.

******* ****** ******* ******** ******* ******* ******* ***
*   Read list FAQ at: http://www.seaint.org/list_FAQ.asp
* 
*   This email was sent to you via Structural Engineers 
*   Association of Southern California (SEAOSC) server. To 
*   subscribe (no fee) or UnSubscribe, please go to:
*
*   http://www.seaint.org/sealist1.asp
*
*   Questions to seaint-ad(--nospam--at)seaint.org. Remember, any email you 
*   send to the list is public domain and may be re-posted 
*   without your permission. Make sure you visit our web 
*   site at: http://www.seaint.org 
******* ****** ****** ****** ******* ****** ****** ******** 





******* ****** ******* ******** ******* ******* ******* ***
*   Read list FAQ at: http://www.seaint.org/list_FAQ.asp
* 
*   This email was sent to you via Structural Engineers 
*   Association of Southern California (SEAOSC) server. To 
*   subscribe (no fee) or UnSubscribe, please go to:
*
*   http://www.seaint.org/sealist1.asp
*
*   Questions to seaint-ad(--nospam--at)seaint.org. Remember, any email you 
*   send to the list is public domain and may be re-posted 
*   without your permission. Make sure you visit our web 
*   site at: http://www.seaint.org 
******* ****** ****** ****** ******* ****** ****** ********