Discussione:
Applicazione addIns per convertire valori
(troppo vecchio per rispondere)
Luca Lenzo
2018-06-25 14:48:55 UTC
Permalink
Salve, buongiorno a tutti,
è da molto che non chiedevo un aiuto a voi che in passato avete risolto molti miei problemi.

questa volta volevo chiedere un favore, io devo convertire da pollici a inches dei valori per poi riconvertirli in millimetri.
Ora, io ho trovato un plug-in che fa ciò che mi serve, ma ho il problema di doverlo attivare ogni volta e se un mio collega apre lo stesso file si trova con degli errori...
Son riuscito quindi a leggere questo codice qua nel Plug-in .

Ma non so come inserirlo per evitare di doverlo "attivare" ogni volta dalle File/opzioni/componenti aggiuntivi/Sfoglia/ etc etc

Chiedevo quindi, è possibile "automatizzare" il tutto?

Grazie a tutti.

Function i2s(inches As Double, Optional sformat As Integer, Optional nofeet As Integer)

Dim tfisep 'seporator between the feet and inches
Dim tinsep 'seporator between the inches and fractional inches numerator


If sformat = 1 Then

tfisep = "-"
tinsep = " "

ElseIf sformat = 2 Then

tfisep = " "
tinsep = " "


ElseIf sformat = 3 Then

tfisep = ""
tinsep = " "

ElseIf sformat = 4 Then

tfisep = " "
tinsep = "-"

ElseIf sformat = 5 Then

tfisep = ""
tinsep = "-"

Else

tfisep = " - "
tinsep = " "

End If


'deal with negative values

Dim x 'used to build the return string
Dim a 'used to store the polarity of the answer


If (inches < 0) Then
x = "-"
a = -inches
Else
x = ""
a = inches
End If



Dim i 'holds the number of residual inches left over


If nofeet = 1 Then

i = a

Else

Dim f 'holds the number of feeet

f = Int(a / 12)

x = x + strt(f) + "'" + tfisep

'find the inches left over

i = a - (f * 12)


End If

'First check if it comes out to an even number of inches

If i = Int(i) Then

'no fractional inches

x = x + strt(i) + Chr(34)

Else

'next check if the number of inches is an even fraction

If (i * 256) = Int(i * 256) Then

Dim iw 'the whole number part of the residual inches

iw = Int(i)

x = x + strt(iw) + tinsep

Dim n 'the nominator of the fractional part of the inches

n = (i - iw) * 256

Dim d 'the denominator of the fractional part of the inches

d = 256

'reduce the faction

Do While (n > 1) And ((n / 2) = Int(n / 2))

n = n / 2
d = d / 2

Loop

x = x + strt(n) + "/" + strt(d) + Chr(34)


Else

'not a fraction, so show the decimal

x = x + strt(i) + Chr(34)

End If

End If


i2s = x

End Function

Private Function strt(i)

strt = Trim(Str(i))

End Function



Private Function parsenum(s As String)

Dim errorflag 'remeber if we hit any errors while decoding the string

errorflag = False

Dim i 'loop var

For i = 1 To Len(s)

Dim c 'step throuhg the string one char at a time and check to make sure all are in range

c = Mid(s, i, 1)

If ((c < "0" Or c > "9") And (c <> ".")) Then

errorflag = True

End If

Next i

If errorflag = True Then

parsenum = CVErr(xlErrNA)

Else

parsenum = Val(s)

End If


End Function


'Convert string to inches
'String in the format 12' 4 1/2"

Function s2i(s As String) As Double


' n = positive or negative
' f= number of feet
' i = number of whole inches
' ifract = fracitonal or decimal inches part

' Get rid of any leading or trailing spaces


s = Trim(s)


Dim n 'save sign of result


If (Len(s) > 0) And Left(s, 1) = "-" Then

n = -1

s = Trim(Mid(s, 2))

Else

n = 1

End If


Dim fp 'feet portion pointer

Dim f 'number of feet


fp = InStr(s, "'")

If (fp > 0) Then

f = parsenum(Left(s, fp - 1))

'f could be an error here - we'll deal with it later

s = Trim(Mid(s, fp + 1))

If (Left(s, 1) = "-") Then

s = Trim(Mid(s, 2))

End If

Else

f = 0

End If

Dim i 'whole number of inches
Dim ifract 'fractional inches

Dim inom 'nominator of fractuional inches
Dim idenom 'nominator of fractuional inches

Dim idec 'decimal portion of inches

If (Len(s) = 0) Then 'just feet, no inches...

i = 0
ifract = 0

Else

'the string must end with a " or it is an error

If Not Right(s, 1) = Chr(34) Then

i = CVErr(xlErrNA)
inom = 0
idenom = 0
idec = 0

Else

'get rid of the "

s = Left(s, Len(s) - 1)


'find space

Dim sp 'space pointer

sp = InStr(s, " ")

'next look for a fractional part

Dim bp 'fraction break pointer

bp = InStr(s, "/")

If bp = 0 And sp = 0 Then 'just a whole number inches? (no space or /)

i = parsenum(s)

ifract = 0

ElseIf bp > 0 And sp > 0 Then 'whole number with fraction?

'The space should never come after the /

If sp > bp Then

i = CVErr(xlErrNA)

ifract = CVErr(xlErrNA)

Else


'get the nom and denom

inom = parsenum(LTrim(Mid(s, sp + 1, bp - sp - 1)))

idenom = parsenum(Mid(s, bp + 1))

If idenom = 0 Then 'dont allow zero denominator

ifract = CVErr(xlErrNA)

Else

ifract = inom / idenom

End If

End If


i = parsenum(Trim(Left(s, sp)))


ElseIf sp = 0 And bp > 0 Then 'just fractional inches part with no whole number?

'get the nom and denom

i = 0

inom = parsenum(LTrim(Mid(s, 1, bp - 1)))

idenom = parsenum(Trim(Mid(s, bp + 1)))

If (idenom = 0) Then

ifract = CVErr(xlErrNA)

Else

ifract = inom / idenom

End If


Else 'fractional part was improperly formatted

i = CVErr(xlErrNA)
ifract = CVErr(xlErrNA)

End If

End If

End If

s2i = ((f * 12) + (i) + (ifract)) * n

End Function

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub
b***@gmail.com
2018-06-25 19:27:30 UTC
Permalink
Post by Luca Lenzo
Salve, buongiorno a tutti,
è da molto che non chiedevo un aiuto a voi che in passato avete risolto molti miei problemi.
questa volta volevo chiedere un favore, io devo convertire da pollici a inches dei valori per poi riconvertirli in millimetri.
Ora, io ho trovato un plug-in che fa ciò che mi serve, ma ho il problema di doverlo attivare ogni volta e se un mio collega apre lo stesso file si trova con degli errori...
Son riuscito quindi a leggere questo codice qua nel Plug-in .
Ma non so come inserirlo per evitare di doverlo "attivare" ogni volta dalle File/opzioni/componenti aggiuntivi/Sfoglia/ etc etc
Chiedevo quindi, è possibile "automatizzare" il tutto?
Grazie a tutti.
Function i2s(inches As Double, Optional sformat As Integer, Optional nofeet As Integer)
Dim tfisep 'seporator between the feet and inches
Dim tinsep 'seporator between the inches and fractional inches numerator
If sformat = 1 Then
tfisep = "-"
tinsep = " "
ElseIf sformat = 2 Then
tfisep = " "
tinsep = " "
ElseIf sformat = 3 Then
tfisep = ""
tinsep = " "
ElseIf sformat = 4 Then
tfisep = " "
tinsep = "-"
ElseIf sformat = 5 Then
tfisep = ""
tinsep = "-"
Else
tfisep = " - "
tinsep = " "
End If
'deal with negative values
Dim x 'used to build the return string
Dim a 'used to store the polarity of the answer
If (inches < 0) Then
x = "-"
a = -inches
Else
x = ""
a = inches
End If
Dim i 'holds the number of residual inches left over
If nofeet = 1 Then
i = a
Else
Dim f 'holds the number of feeet
f = Int(a / 12)
x = x + strt(f) + "'" + tfisep
'find the inches left over
i = a - (f * 12)
End If
'First check if it comes out to an even number of inches
If i = Int(i) Then
'no fractional inches
x = x + strt(i) + Chr(34)
Else
'next check if the number of inches is an even fraction
If (i * 256) = Int(i * 256) Then
Dim iw 'the whole number part of the residual inches
iw = Int(i)
x = x + strt(iw) + tinsep
Dim n 'the nominator of the fractional part of the inches
n = (i - iw) * 256
Dim d 'the denominator of the fractional part of the inches
d = 256
'reduce the faction
Do While (n > 1) And ((n / 2) = Int(n / 2))
n = n / 2
d = d / 2
Loop
x = x + strt(n) + "/" + strt(d) + Chr(34)
Else
'not a fraction, so show the decimal
x = x + strt(i) + Chr(34)
End If
End If
i2s = x
End Function
Private Function strt(i)
strt = Trim(Str(i))
End Function
Private Function parsenum(s As String)
Dim errorflag 'remeber if we hit any errors while decoding the string
errorflag = False
Dim i 'loop var
For i = 1 To Len(s)
Dim c 'step throuhg the string one char at a time and check to make sure all are in range
c = Mid(s, i, 1)
If ((c < "0" Or c > "9") And (c <> ".")) Then
errorflag = True
End If
Next i
If errorflag = True Then
parsenum = CVErr(xlErrNA)
Else
parsenum = Val(s)
End If
End Function
'Convert string to inches
'String in the format 12' 4 1/2"
Function s2i(s As String) As Double
' n = positive or negative
' f= number of feet
' i = number of whole inches
' ifract = fracitonal or decimal inches part
' Get rid of any leading or trailing spaces
s = Trim(s)
Dim n 'save sign of result
If (Len(s) > 0) And Left(s, 1) = "-" Then
n = -1
s = Trim(Mid(s, 2))
Else
n = 1
End If
Dim fp 'feet portion pointer
Dim f 'number of feet
fp = InStr(s, "'")
If (fp > 0) Then
f = parsenum(Left(s, fp - 1))
'f could be an error here - we'll deal with it later
s = Trim(Mid(s, fp + 1))
If (Left(s, 1) = "-") Then
s = Trim(Mid(s, 2))
End If
Else
f = 0
End If
Dim i 'whole number of inches
Dim ifract 'fractional inches
Dim inom 'nominator of fractuional inches
Dim idenom 'nominator of fractuional inches
Dim idec 'decimal portion of inches
If (Len(s) = 0) Then 'just feet, no inches...
i = 0
ifract = 0
Else
'the string must end with a " or it is an error
If Not Right(s, 1) = Chr(34) Then
i = CVErr(xlErrNA)
inom = 0
idenom = 0
idec = 0
Else
'get rid of the "
s = Left(s, Len(s) - 1)
'find space
Dim sp 'space pointer
sp = InStr(s, " ")
'next look for a fractional part
Dim bp 'fraction break pointer
bp = InStr(s, "/")
If bp = 0 And sp = 0 Then 'just a whole number inches? (no space or /)
i = parsenum(s)
ifract = 0
ElseIf bp > 0 And sp > 0 Then 'whole number with fraction?
'The space should never come after the /
If sp > bp Then
i = CVErr(xlErrNA)
ifract = CVErr(xlErrNA)
Else
'get the nom and denom
inom = parsenum(LTrim(Mid(s, sp + 1, bp - sp - 1)))
idenom = parsenum(Mid(s, bp + 1))
If idenom = 0 Then 'dont allow zero denominator
ifract = CVErr(xlErrNA)
Else
ifract = inom / idenom
End If
End If
i = parsenum(Trim(Left(s, sp)))
ElseIf sp = 0 And bp > 0 Then 'just fractional inches part with no whole number?
'get the nom and denom
i = 0
inom = parsenum(LTrim(Mid(s, 1, bp - 1)))
idenom = parsenum(Trim(Mid(s, bp + 1)))
If (idenom = 0) Then
ifract = CVErr(xlErrNA)
Else
ifract = inom / idenom
End If
Else 'fractional part was improperly formatted
i = CVErr(xlErrNA)
ifract = CVErr(xlErrNA)
End If
End If
End If
s2i = ((f * 12) + (i) + (ifract)) * n
End Function
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Per Plug-in intendi un Add-in con estensione .xla o xlam? Se è così non vedo perché tu debba attivare o disattivare ogni volta il componente aggiuntivo. Se il tuo collega non usa le funzioni dell'Add-In che problema dovrebbe avere? Al massimo quando apre Excel può passare qualche secondo per aspettare che l'applicazione carichi l'Add-In. Se poi le funzioni ti servono solo su un file che usi solo tu allora ti carichi le funzioni su questo file salvato poi con con estensione xlsm.
Ciao
Elio
n***@gmail.com
2018-06-26 06:41:14 UTC
Permalink
Post by b***@gmail.com
Post by Luca Lenzo
Salve, buongiorno a tutti,
è da molto che non chiedevo un aiuto a voi che in passato avete risolto molti miei problemi.
questa volta volevo chiedere un favore, io devo convertire da pollici a inches dei valori per poi riconvertirli in millimetri.
Ora, io ho trovato un plug-in che fa ciò che mi serve, ma ho il problema di doverlo attivare ogni volta e se un mio collega apre lo stesso file si trova con degli errori...
Son riuscito quindi a leggere questo codice qua nel Plug-in .
Ma non so come inserirlo per evitare di doverlo "attivare" ogni volta dalle File/opzioni/componenti aggiuntivi/Sfoglia/ etc etc
Chiedevo quindi, è possibile "automatizzare" il tutto?
Grazie a tutti.
Function i2s(inches As Double, Optional sformat As Integer, Optional nofeet As Integer)
Dim tfisep 'seporator between the feet and inches
Dim tinsep 'seporator between the inches and fractional inches numerator
If sformat = 1 Then
tfisep = "-"
tinsep = " "
ElseIf sformat = 2 Then
tfisep = " "
tinsep = " "
ElseIf sformat = 3 Then
tfisep = ""
tinsep = " "
ElseIf sformat = 4 Then
tfisep = " "
tinsep = "-"
ElseIf sformat = 5 Then
tfisep = ""
tinsep = "-"
Else
tfisep = " - "
tinsep = " "
End If
'deal with negative values
Dim x 'used to build the return string
Dim a 'used to store the polarity of the answer
If (inches < 0) Then
x = "-"
a = -inches
Else
x = ""
a = inches
End If
Dim i 'holds the number of residual inches left over
If nofeet = 1 Then
i = a
Else
Dim f 'holds the number of feeet
f = Int(a / 12)
x = x + strt(f) + "'" + tfisep
'find the inches left over
i = a - (f * 12)
End If
'First check if it comes out to an even number of inches
If i = Int(i) Then
'no fractional inches
x = x + strt(i) + Chr(34)
Else
'next check if the number of inches is an even fraction
If (i * 256) = Int(i * 256) Then
Dim iw 'the whole number part of the residual inches
iw = Int(i)
x = x + strt(iw) + tinsep
Dim n 'the nominator of the fractional part of the inches
n = (i - iw) * 256
Dim d 'the denominator of the fractional part of the inches
d = 256
'reduce the faction
Do While (n > 1) And ((n / 2) = Int(n / 2))
n = n / 2
d = d / 2
Loop
x = x + strt(n) + "/" + strt(d) + Chr(34)
Else
'not a fraction, so show the decimal
x = x + strt(i) + Chr(34)
End If
End If
i2s = x
End Function
Private Function strt(i)
strt = Trim(Str(i))
End Function
Private Function parsenum(s As String)
Dim errorflag 'remeber if we hit any errors while decoding the string
errorflag = False
Dim i 'loop var
For i = 1 To Len(s)
Dim c 'step throuhg the string one char at a time and check to make sure all are in range
c = Mid(s, i, 1)
If ((c < "0" Or c > "9") And (c <> ".")) Then
errorflag = True
End If
Next i
If errorflag = True Then
parsenum = CVErr(xlErrNA)
Else
parsenum = Val(s)
End If
End Function
'Convert string to inches
'String in the format 12' 4 1/2"
Function s2i(s As String) As Double
' n = positive or negative
' f= number of feet
' i = number of whole inches
' ifract = fracitonal or decimal inches part
' Get rid of any leading or trailing spaces
s = Trim(s)
Dim n 'save sign of result
If (Len(s) > 0) And Left(s, 1) = "-" Then
n = -1
s = Trim(Mid(s, 2))
Else
n = 1
End If
Dim fp 'feet portion pointer
Dim f 'number of feet
fp = InStr(s, "'")
If (fp > 0) Then
f = parsenum(Left(s, fp - 1))
'f could be an error here - we'll deal with it later
s = Trim(Mid(s, fp + 1))
If (Left(s, 1) = "-") Then
s = Trim(Mid(s, 2))
End If
Else
f = 0
End If
Dim i 'whole number of inches
Dim ifract 'fractional inches
Dim inom 'nominator of fractuional inches
Dim idenom 'nominator of fractuional inches
Dim idec 'decimal portion of inches
If (Len(s) = 0) Then 'just feet, no inches...
i = 0
ifract = 0
Else
'the string must end with a " or it is an error
If Not Right(s, 1) = Chr(34) Then
i = CVErr(xlErrNA)
inom = 0
idenom = 0
idec = 0
Else
'get rid of the "
s = Left(s, Len(s) - 1)
'find space
Dim sp 'space pointer
sp = InStr(s, " ")
'next look for a fractional part
Dim bp 'fraction break pointer
bp = InStr(s, "/")
If bp = 0 And sp = 0 Then 'just a whole number inches? (no space or /)
i = parsenum(s)
ifract = 0
ElseIf bp > 0 And sp > 0 Then 'whole number with fraction?
'The space should never come after the /
If sp > bp Then
i = CVErr(xlErrNA)
ifract = CVErr(xlErrNA)
Else
'get the nom and denom
inom = parsenum(LTrim(Mid(s, sp + 1, bp - sp - 1)))
idenom = parsenum(Mid(s, bp + 1))
If idenom = 0 Then 'dont allow zero denominator
ifract = CVErr(xlErrNA)
Else
ifract = inom / idenom
End If
End If
i = parsenum(Trim(Left(s, sp)))
ElseIf sp = 0 And bp > 0 Then 'just fractional inches part with no whole number?
'get the nom and denom
i = 0
inom = parsenum(LTrim(Mid(s, 1, bp - 1)))
idenom = parsenum(Trim(Mid(s, bp + 1)))
If (idenom = 0) Then
ifract = CVErr(xlErrNA)
Else
ifract = inom / idenom
End If
Else 'fractional part was improperly formatted
i = CVErr(xlErrNA)
ifract = CVErr(xlErrNA)
End If
End If
End If
s2i = ((f * 12) + (i) + (ifract)) * n
End Function
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Per Plug-in intendi un Add-in con estensione .xla o xlam? Se è così non vedo perché tu debba attivare o disattivare ogni volta il componente aggiuntivo. Se il tuo collega non usa le funzioni dell'Add-In che problema dovrebbe avere? Al massimo quando apre Excel può passare qualche secondo per aspettare che l'applicazione carichi l'Add-In. Se poi le funzioni ti servono solo su un file che usi solo tu allora ti carichi le funzioni su questo file salvato poi con con estensione xlsm.
Ciao
Elio
Grazie intanto, il file è con estensione xla. Io non so come funzionano questi componenti aggiuntivi, ho solo capito che devo attivarli perché funzionino. Poi se chiudo il file è lo riapro, se non rifaccio la procedura, nella cella appare l errore come risultato, e se ci vado sopra noto che nella riga di comando appare una directory lunga che riporta al file xla. Il file che utilizzo io è xlsm.
Altro non so. Quello che servirebbe a me è che chi apre quel file non legga l errore nelle celle. Magari se hai voglia domani da lavoro ti mando i 2 file, o altrimenti cerco di trovare altra soluzione.
Grazie ancora intanto, buona serata.
b***@gmail.com
2018-06-27 14:45:43 UTC
Permalink
Post by n***@gmail.com
Post by b***@gmail.com
Post by Luca Lenzo
Salve, buongiorno a tutti,
è da molto che non chiedevo un aiuto a voi che in passato avete risolto molti miei problemi.
questa volta volevo chiedere un favore, io devo convertire da pollici a inches dei valori per poi riconvertirli in millimetri.
Ora, io ho trovato un plug-in che fa ciò che mi serve, ma ho il problema di doverlo attivare ogni volta e se un mio collega apre lo stesso file si trova con degli errori...
Son riuscito quindi a leggere questo codice qua nel Plug-in .
Ma non so come inserirlo per evitare di doverlo "attivare" ogni volta dalle File/opzioni/componenti aggiuntivi/Sfoglia/ etc etc
Chiedevo quindi, è possibile "automatizzare" il tutto?
Grazie a tutti.
Function i2s(inches As Double, Optional sformat As Integer, Optional nofeet As Integer)
Dim tfisep 'seporator between the feet and inches
Dim tinsep 'seporator between the inches and fractional inches numerator
If sformat = 1 Then
tfisep = "-"
tinsep = " "
ElseIf sformat = 2 Then
tfisep = " "
tinsep = " "
ElseIf sformat = 3 Then
tfisep = ""
tinsep = " "
ElseIf sformat = 4 Then
tfisep = " "
tinsep = "-"
ElseIf sformat = 5 Then
tfisep = ""
tinsep = "-"
Else
tfisep = " - "
tinsep = " "
End If
'deal with negative values
Dim x 'used to build the return string
Dim a 'used to store the polarity of the answer
If (inches < 0) Then
x = "-"
a = -inches
Else
x = ""
a = inches
End If
Dim i 'holds the number of residual inches left over
If nofeet = 1 Then
i = a
Else
Dim f 'holds the number of feeet
f = Int(a / 12)
x = x + strt(f) + "'" + tfisep
'find the inches left over
i = a - (f * 12)
End If
'First check if it comes out to an even number of inches
If i = Int(i) Then
'no fractional inches
x = x + strt(i) + Chr(34)
Else
'next check if the number of inches is an even fraction
If (i * 256) = Int(i * 256) Then
Dim iw 'the whole number part of the residual inches
iw = Int(i)
x = x + strt(iw) + tinsep
Dim n 'the nominator of the fractional part of the inches
n = (i - iw) * 256
Dim d 'the denominator of the fractional part of the inches
d = 256
'reduce the faction
Do While (n > 1) And ((n / 2) = Int(n / 2))
n = n / 2
d = d / 2
Loop
x = x + strt(n) + "/" + strt(d) + Chr(34)
Else
'not a fraction, so show the decimal
x = x + strt(i) + Chr(34)
End If
End If
i2s = x
End Function
Private Function strt(i)
strt = Trim(Str(i))
End Function
Private Function parsenum(s As String)
Dim errorflag 'remeber if we hit any errors while decoding the string
errorflag = False
Dim i 'loop var
For i = 1 To Len(s)
Dim c 'step throuhg the string one char at a time and check to make sure all are in range
c = Mid(s, i, 1)
If ((c < "0" Or c > "9") And (c <> ".")) Then
errorflag = True
End If
Next i
If errorflag = True Then
parsenum = CVErr(xlErrNA)
Else
parsenum = Val(s)
End If
End Function
'Convert string to inches
'String in the format 12' 4 1/2"
Function s2i(s As String) As Double
' n = positive or negative
' f= number of feet
' i = number of whole inches
' ifract = fracitonal or decimal inches part
' Get rid of any leading or trailing spaces
s = Trim(s)
Dim n 'save sign of result
If (Len(s) > 0) And Left(s, 1) = "-" Then
n = -1
s = Trim(Mid(s, 2))
Else
n = 1
End If
Dim fp 'feet portion pointer
Dim f 'number of feet
fp = InStr(s, "'")
If (fp > 0) Then
f = parsenum(Left(s, fp - 1))
'f could be an error here - we'll deal with it later
s = Trim(Mid(s, fp + 1))
If (Left(s, 1) = "-") Then
s = Trim(Mid(s, 2))
End If
Else
f = 0
End If
Dim i 'whole number of inches
Dim ifract 'fractional inches
Dim inom 'nominator of fractuional inches
Dim idenom 'nominator of fractuional inches
Dim idec 'decimal portion of inches
If (Len(s) = 0) Then 'just feet, no inches...
i = 0
ifract = 0
Else
'the string must end with a " or it is an error
If Not Right(s, 1) = Chr(34) Then
i = CVErr(xlErrNA)
inom = 0
idenom = 0
idec = 0
Else
'get rid of the "
s = Left(s, Len(s) - 1)
'find space
Dim sp 'space pointer
sp = InStr(s, " ")
'next look for a fractional part
Dim bp 'fraction break pointer
bp = InStr(s, "/")
If bp = 0 And sp = 0 Then 'just a whole number inches? (no space or /)
i = parsenum(s)
ifract = 0
ElseIf bp > 0 And sp > 0 Then 'whole number with fraction?
'The space should never come after the /
If sp > bp Then
i = CVErr(xlErrNA)
ifract = CVErr(xlErrNA)
Else
'get the nom and denom
inom = parsenum(LTrim(Mid(s, sp + 1, bp - sp - 1)))
idenom = parsenum(Mid(s, bp + 1))
If idenom = 0 Then 'dont allow zero denominator
ifract = CVErr(xlErrNA)
Else
ifract = inom / idenom
End If
End If
i = parsenum(Trim(Left(s, sp)))
ElseIf sp = 0 And bp > 0 Then 'just fractional inches part with no whole number?
'get the nom and denom
i = 0
inom = parsenum(LTrim(Mid(s, 1, bp - 1)))
idenom = parsenum(Trim(Mid(s, bp + 1)))
If (idenom = 0) Then
ifract = CVErr(xlErrNA)
Else
ifract = inom / idenom
End If
Else 'fractional part was improperly formatted
i = CVErr(xlErrNA)
ifract = CVErr(xlErrNA)
End If
End If
End If
s2i = ((f * 12) + (i) + (ifract)) * n
End Function
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Per Plug-in intendi un Add-in con estensione .xla o xlam? Se è così non vedo perché tu debba attivare o disattivare ogni volta il componente aggiuntivo. Se il tuo collega non usa le funzioni dell'Add-In che problema dovrebbe avere? Al massimo quando apre Excel può passare qualche secondo per aspettare che l'applicazione carichi l'Add-In. Se poi le funzioni ti servono solo su un file che usi solo tu allora ti carichi le funzioni su questo file salvato poi con con estensione xlsm.
Ciao
Elio
Grazie intanto, il file è con estensione xla. Io non so come funzionano questi componenti aggiuntivi, ho solo capito che devo attivarli perché funzionino. Poi se chiudo il file è lo riapro, se non rifaccio la procedura, nella cella appare l errore come risultato, e se ci vado sopra noto che nella riga di comando appare una directory lunga che riporta al file xla. Il file che utilizzo io è xlsm.
Altro non so. Quello che servirebbe a me è che chi apre quel file non legga l errore nelle celle. Magari se hai voglia domani da lavoro ti mando i 2 file, o altrimenti cerco di trovare altra soluzione.
Grazie ancora intanto, buona serata.
manda pure i file
b***@gmail.com
2018-06-28 19:32:39 UTC
Permalink
Il file .xla non contiene codice. Il file .xls contiene collegamenti alle funzioni del file .xla che ovviamente non vengono trovate. Ho aperto un file excel nuovo; ho salvato il codice che hai postato in un modulo standard omettendo solo le righe
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

che hanno senso solo in un modulo di classe del foglio di lavoro;
ho salvato il file con nome InchCalc(1).xla nella cartella degli Add-In che in Excel 2013 è:

C:\Users\<NomeUtente>\AppData\Roaming\Microsoft\AddIns
Ho aperto un qualsiasi file di Excel e in File>Opzioni>Componenti aggiuntivi>Comando Vai... all'altezza dell'etichetta Gestisci > Flag su opzione di InchCalc(1).xla della finestra Componenti Aggiuntivi.
Ho aperto il file da te inviato .xls e sostituito formule con collegamenti esterni con formule senza collegamenti esterni esemplificando

=('C:\Users\l.lenzo\AppData\Roaming\Microsoft\AddIns\InchCalc (1).xla'!s2i(J4)-L4)/2

diventa
=s2i(J4)-L4/2

la funzione s2i è visibile da tutti i file excel.
Ad esempio ne apro uno vuoto, immetto 7'-3" in A1 e in B1 =s2i(A1)e ottengo 87

A meno di non togliere la spunta al file .xla nella finestra dei componenti aggiuntivi ad ogni apertura di Excel il file .xla viene caricato in maniera 'invisibile' e le sue funzioni esposte a file excel aperti

Ciao
Elio
n***@gmail.com
2018-06-29 10:27:31 UTC
Permalink
Post by b***@gmail.com
Il file .xla non contiene codice. Il file .xls contiene collegamenti alle funzioni del file .xla che ovviamente non vengono trovate. Ho aperto un file excel nuovo; ho salvato il codice che hai postato in un modulo standard omettendo solo le righe
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
che hanno senso solo in un modulo di classe del foglio di lavoro;
C:\Users\<NomeUtente>\AppData\Roaming\Microsoft\AddIns
Ho aperto un qualsiasi file di Excel e in File>Opzioni>Componenti aggiuntivi>Comando Vai... all'altezza dell'etichetta Gestisci > Flag su opzione di InchCalc(1).xla della finestra Componenti Aggiuntivi.
Ho aperto il file da te inviato .xls e sostituito formule con collegamenti esterni con formule senza collegamenti esterni esemplificando
=('C:\Users\l.lenzo\AppData\Roaming\Microsoft\AddIns\InchCalc (1).xla'!s2i(J4)-L4)/2
diventa
=s2i(J4)-L4/2
la funzione s2i è visibile da tutti i file excel.
Ad esempio ne apro uno vuoto, immetto 7'-3" in A1 e in B1 =s2i(A1)e ottengo 87
A meno di non togliere la spunta al file .xla nella finestra dei componenti aggiuntivi ad ogni apertura di Excel il file .xla viene caricato in maniera 'invisibile' e le sue funzioni esposte a file excel aperti
Ciao
Elio
Grazie mille della pazienza, ho provato secondo indicazioni ma il problema mi si ripresenta.
In pratica se io uso il file va tutto bene, quando chiudo tutto e riapro la cella che contiene la formula "= s2i(J17)" si trasforma con il percorso =('C:\Users\<utente>\AppData\Roaming\Microsoft\AddIns\InchCalc.xla'!s2i(J17)

questo causa 2 cose : 1_ se continuo il lavoro la cella "non lavora" se non gli rifaccio l'attivazione. 2_ se un altro utente apre lo stesso file gli da errore e deve riattivare cambiando percorso logicamente e facendolo puntare nel suo C:\Users\<utente>\AppData\Roaming\Microsoft\AddIns\InchCalc.xla'


Detto che questa utilità mi serve solo ogni tanto volevo capire se la potevo inserire solo in questo file e che fosse usufruibile da tutte le persone che aprono questo e solo questo file.
Tipo un codice da inserire..... io non son pratico purtroppo.

Vi ringrazio sempre e comunque........

Buona giornata.
b***@gmail.com
2018-07-02 23:05:26 UTC
Permalink
Post by n***@gmail.com
Post by b***@gmail.com
Il file .xla non contiene codice. Il file .xls contiene collegamenti alle funzioni del file .xla che ovviamente non vengono trovate. Ho aperto un file excel nuovo; ho salvato il codice che hai postato in un modulo standard omettendo solo le righe
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
che hanno senso solo in un modulo di classe del foglio di lavoro;
C:\Users\<NomeUtente>\AppData\Roaming\Microsoft\AddIns
Ho aperto un qualsiasi file di Excel e in File>Opzioni>Componenti aggiuntivi>Comando Vai... all'altezza dell'etichetta Gestisci > Flag su opzione di InchCalc(1).xla della finestra Componenti Aggiuntivi.
Ho aperto il file da te inviato .xls e sostituito formule con collegamenti esterni con formule senza collegamenti esterni esemplificando
=('C:\Users\l.lenzo\AppData\Roaming\Microsoft\AddIns\InchCalc (1).xla'!s2i(J4)-L4)/2
diventa
=s2i(J4)-L4/2
la funzione s2i è visibile da tutti i file excel.
Ad esempio ne apro uno vuoto, immetto 7'-3" in A1 e in B1 =s2i(A1)e ottengo 87
A meno di non togliere la spunta al file .xla nella finestra dei componenti aggiuntivi ad ogni apertura di Excel il file .xla viene caricato in maniera 'invisibile' e le sue funzioni esposte a file excel aperti
Ciao
Elio
Grazie mille della pazienza, ho provato secondo indicazioni ma il problema mi si ripresenta.
In pratica se io uso il file va tutto bene, quando chiudo tutto e riapro la cella che contiene la formula "= s2i(J17)" si trasforma con il percorso =('C:\Users\<utente>\AppData\Roaming\Microsoft\AddIns\InchCalc.xla'!s2i(J17)
questo causa 2 cose : 1_ se continuo il lavoro la cella "non lavora" se non gli rifaccio l'attivazione. 2_ se un altro utente apre lo stesso file gli da errore e deve riattivare cambiando percorso logicamente e facendolo puntare nel suo C:\Users\<utente>\AppData\Roaming\Microsoft\AddIns\InchCalc.xla'
Detto che questa utilità mi serve solo ogni tanto volevo capire se la potevo inserire solo in questo file e che fosse usufruibile da tutte le persone che aprono questo e solo questo file.
Tipo un codice da inserire..... io non son pratico purtroppo.
Vi ringrazio sempre e comunque........
Buona giornata.
Segui le istruzioni precedenti salvando il file non come componente aggiuntivo ma solo come xls (formato 97-2003) oppure xlsm (formato 2007 )
Post by n***@gmail.com
Ho aperto un file excel nuovo; ho salvato il codice che hai postato in un >modulo standard omettendo solo le righe
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
che hanno senso solo in un modulo di classe del foglio di lavoro;
Elio
n***@gmail.com
2018-07-06 14:14:36 UTC
Permalink
Post by b***@gmail.com
Post by n***@gmail.com
Post by b***@gmail.com
Il file .xla non contiene codice. Il file .xls contiene collegamenti alle funzioni del file .xla che ovviamente non vengono trovate. Ho aperto un file excel nuovo; ho salvato il codice che hai postato in un modulo standard omettendo solo le righe
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
che hanno senso solo in un modulo di classe del foglio di lavoro;
C:\Users\<NomeUtente>\AppData\Roaming\Microsoft\AddIns
Ho aperto un qualsiasi file di Excel e in File>Opzioni>Componenti aggiuntivi>Comando Vai... all'altezza dell'etichetta Gestisci > Flag su opzione di InchCalc(1).xla della finestra Componenti Aggiuntivi.
Ho aperto il file da te inviato .xls e sostituito formule con collegamenti esterni con formule senza collegamenti esterni esemplificando
=('C:\Users\l.lenzo\AppData\Roaming\Microsoft\AddIns\InchCalc (1).xla'!s2i(J4)-L4)/2
diventa
=s2i(J4)-L4/2
la funzione s2i è visibile da tutti i file excel.
Ad esempio ne apro uno vuoto, immetto 7'-3" in A1 e in B1 =s2i(A1)e ottengo 87
A meno di non togliere la spunta al file .xla nella finestra dei componenti aggiuntivi ad ogni apertura di Excel il file .xla viene caricato in maniera 'invisibile' e le sue funzioni esposte a file excel aperti
Ciao
Elio
Grazie mille della pazienza, ho provato secondo indicazioni ma il problema mi si ripresenta.
In pratica se io uso il file va tutto bene, quando chiudo tutto e riapro la cella che contiene la formula "= s2i(J17)" si trasforma con il percorso =('C:\Users\<utente>\AppData\Roaming\Microsoft\AddIns\InchCalc.xla'!s2i(J17)
questo causa 2 cose : 1_ se continuo il lavoro la cella "non lavora" se non gli rifaccio l'attivazione. 2_ se un altro utente apre lo stesso file gli da errore e deve riattivare cambiando percorso logicamente e facendolo puntare nel suo C:\Users\<utente>\AppData\Roaming\Microsoft\AddIns\InchCalc.xla'
Detto che questa utilità mi serve solo ogni tanto volevo capire se la potevo inserire solo in questo file e che fosse usufruibile da tutte le persone che aprono questo e solo questo file.
Tipo un codice da inserire..... io non son pratico purtroppo.
Vi ringrazio sempre e comunque........
Buona giornata.
Segui le istruzioni precedenti salvando il file non come componente aggiuntivo ma solo come xls (formato 97-2003) oppure xlsm (formato 2007 )
Post by n***@gmail.com
Ho aperto un file excel nuovo; ho salvato il codice che hai postato in un >modulo standard omettendo solo le righe
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
che hanno senso solo in un modulo di classe del foglio di lavoro;
Elio
e...ninete.
Non importa dai, grazie comunque.
Evidentemente sbaglio qualcosa.

Magari riproverò più avanti..... dopo le ferie.. perchè adesso sono un poco fuso.....
grazie ancora Elio
casanmaner
2018-07-06 14:24:43 UTC
Permalink
Post by n***@gmail.com
Magari riproverò più avanti..... dopo le ferie.. perchè adesso sono un poco fuso.....
grazie ancora Elio
Ma è possibile accedere al progetto VBA dell'Addin?
Perché in tal caso ti basterebbe copiare i moduli dove sono presenti le funzioni di tuo interesse nel progetto vba del file che utilizza quelle formule in modo che siano disponibili in maniera permanente e a prescindere da quale postazione il file viene utilizzato.
n***@gmail.com
2018-07-06 16:08:43 UTC
Permalink
Post by casanmaner
Post by n***@gmail.com
Magari riproverò più avanti..... dopo le ferie.. perchè adesso sono un poco fuso.....
grazie ancora Elio
Ma è possibile accedere al progetto VBA dell'Addin?
Perché in tal caso ti basterebbe copiare i moduli dove sono presenti le funzioni di tuo interesse nel progetto vba del file che utilizza quelle formule in modo che siano disponibili in maniera permanente e a prescindere da quale postazione il file viene utilizzato.
In effetti è quello che volevo fare io.
Ma non so come si fa.
Non so come , sono riuscito a trovare questo codice dal file xla:


unction i2s(inches As Double, Optional sformat As Integer, Optional nofeet As Integer)

Dim tfisep 'seporator between the feet and inches
Dim tinsep 'seporator between the inches and fractional inches numerator


If sformat = 1 Then

tfisep = "-"
tinsep = " "

ElseIf sformat = 2 Then

tfisep = " "
tinsep = " "


ElseIf sformat = 3 Then

tfisep = ""
tinsep = " "

ElseIf sformat = 4 Then

tfisep = " "
tinsep = "-"

ElseIf sformat = 5 Then

tfisep = ""
tinsep = "-"

Else

tfisep = " - "
tinsep = " "

End If


'deal with negative values

Dim x 'used to build the return string
Dim a 'used to store the polarity of the answer


If (inches < 0) Then
x = "-"
a = -inches
Else
x = ""
a = inches
End If



Dim i 'holds the number of residual inches left over


If nofeet = 1 Then

i = a

Else

Dim f 'holds the number of feeet

f = Int(a / 12)

x = x + strt(f) + "'" + tfisep

'find the inches left over

i = a - (f * 12)


End If

'First check if it comes out to an even number of inches

If i = Int(i) Then

'no fractional inches

x = x + strt(i) + Chr(34)

Else

'next check if the number of inches is an even fraction

If (i * 256) = Int(i * 256) Then

Dim iw 'the whole number part of the residual inches

iw = Int(i)

x = x + strt(iw) + tinsep

Dim n 'the nominator of the fractional part of the inches

n = (i - iw) * 256

Dim d 'the denominator of the fractional part of the inches

d = 256

'reduce the faction

Do While (n > 1) And ((n / 2) = Int(n / 2))

n = n / 2
d = d / 2

Loop

x = x + strt(n) + "/" + strt(d) + Chr(34)


Else

'not a fraction, so show the decimal

x = x + strt(i) + Chr(34)

End If

End If


i2s = x

End Function

Private Function strt(i)

strt = Trim(Str(i))

End Function



Private Function parsenum(s As String)

Dim errorflag 'remeber if we hit any errors while decoding the string

errorflag = False

Dim i 'loop var

For i = 1 To Len(s)

Dim c 'step throuhg the string one char at a time and check to make sure all are in range

c = Mid(s, i, 1)

If ((c < "0" Or c > "9") And (c <> ".")) Then

errorflag = True

End If

Next i

If errorflag = True Then

parsenum = CVErr(xlErrNA)

Else

parsenum = Val(s)

End If


End Function


'Convert string to inches
'String in the format 12' 4 1/2"

Function s2i(s As String) As Double


' n = positive or negative
' f= number of feet
' i = number of whole inches
' ifract = fracitonal or decimal inches part

' Get rid of any leading or trailing spaces


s = Trim(s)


Dim n 'save sign of result


If (Len(s) > 0) And Left(s, 1) = "-" Then

n = -1

s = Trim(Mid(s, 2))

Else

n = 1

End If


Dim fp 'feet portion pointer

Dim f 'number of feet


fp = InStr(s, "'")

If (fp > 0) Then

f = parsenum(Left(s, fp - 1))

'f could be an error here - we'll deal with it later

s = Trim(Mid(s, fp + 1))

If (Left(s, 1) = "-") Then

s = Trim(Mid(s, 2))

End If

Else

f = 0

End If

Dim i 'whole number of inches
Dim ifract 'fractional inches

Dim inom 'nominator of fractuional inches
Dim idenom 'nominator of fractuional inches

Dim idec 'decimal portion of inches

If (Len(s) = 0) Then 'just feet, no inches...

i = 0
ifract = 0

Else

'the string must end with a " or it is an error

If Not Right(s, 1) = Chr(34) Then

i = CVErr(xlErrNA)
inom = 0
idenom = 0
idec = 0

Else

'get rid of the "

s = Left(s, Len(s) - 1)


'find space

Dim sp 'space pointer

sp = InStr(s, " ")

'next look for a fractional part

Dim bp 'fraction break pointer

bp = InStr(s, "/")

If bp = 0 And sp = 0 Then 'just a whole number inches? (no space or /)

i = parsenum(s)

ifract = 0

ElseIf bp > 0 And sp > 0 Then 'whole number with fraction?

'The space should never come after the /

If sp > bp Then

i = CVErr(xlErrNA)

ifract = CVErr(xlErrNA)

Else


'get the nom and denom

inom = parsenum(LTrim(Mid(s, sp + 1, bp - sp - 1)))

idenom = parsenum(Mid(s, bp + 1))

If idenom = 0 Then 'dont allow zero denominator

ifract = CVErr(xlErrNA)

Else

ifract = inom / idenom

End If

End If


i = parsenum(Trim(Left(s, sp)))


ElseIf sp = 0 And bp > 0 Then 'just fractional inches part with no whole number?

'get the nom and denom

i = 0

inom = parsenum(LTrim(Mid(s, 1, bp - 1)))

idenom = parsenum(Trim(Mid(s, bp + 1)))

If (idenom = 0) Then

ifract = CVErr(xlErrNA)

Else

ifract = inom / idenom

End If


Else 'fractional part was improperly formatted

i = CVErr(xlErrNA)
ifract = CVErr(xlErrNA)

End If

End If

End If

s2i = ((f * 12) + (i) + (ifract)) * n

End Function

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub


MA non so come modificarlo per farlo funzionare.
( ho provato omettendo le righe che mi consigliava Elio ) .

E poi, basta incollarlo in < Sviluppo/Visual basic/visualizza codice > ??????


Grazie.
casanmaner
2018-07-06 17:01:48 UTC
Permalink
Post by n***@gmail.com
Post by casanmaner
Post by n***@gmail.com
Magari riproverò più avanti..... dopo le ferie.. perchè adesso sono un poco fuso.....
grazie ancora Elio
Ma è possibile accedere al progetto VBA dell'Addin?
Perché in tal caso ti basterebbe copiare i moduli dove sono presenti le funzioni di tuo interesse nel progetto vba del file che utilizza quelle formule in modo che siano disponibili in maniera permanente e a prescindere da quale postazione il file viene utilizzato.
In effetti è quello che volevo fare io.
Ma non so come si fa.
unction i2s(inches As Double, Optional sformat As Integer, Optional nofeet As Integer)
Dim tfisep 'seporator between the feet and inches
Dim tinsep 'seporator between the inches and fractional inches numerator
If sformat = 1 Then
tfisep = "-"
tinsep = " "
ElseIf sformat = 2 Then
tfisep = " "
tinsep = " "
ElseIf sformat = 3 Then
tfisep = ""
tinsep = " "
ElseIf sformat = 4 Then
tfisep = " "
tinsep = "-"
ElseIf sformat = 5 Then
tfisep = ""
tinsep = "-"
Else
tfisep = " - "
tinsep = " "
End If
'deal with negative values
Dim x 'used to build the return string
Dim a 'used to store the polarity of the answer
If (inches < 0) Then
x = "-"
a = -inches
Else
x = ""
a = inches
End If
Dim i 'holds the number of residual inches left over
If nofeet = 1 Then
i = a
Else
Dim f 'holds the number of feeet
f = Int(a / 12)
x = x + strt(f) + "'" + tfisep
'find the inches left over
i = a - (f * 12)
End If
'First check if it comes out to an even number of inches
If i = Int(i) Then
'no fractional inches
x = x + strt(i) + Chr(34)
Else
'next check if the number of inches is an even fraction
If (i * 256) = Int(i * 256) Then
Dim iw 'the whole number part of the residual inches
iw = Int(i)
x = x + strt(iw) + tinsep
Dim n 'the nominator of the fractional part of the inches
n = (i - iw) * 256
Dim d 'the denominator of the fractional part of the inches
d = 256
'reduce the faction
Do While (n > 1) And ((n / 2) = Int(n / 2))
n = n / 2
d = d / 2
Loop
x = x + strt(n) + "/" + strt(d) + Chr(34)
Else
'not a fraction, so show the decimal
x = x + strt(i) + Chr(34)
End If
End If
i2s = x
End Function
Private Function strt(i)
strt = Trim(Str(i))
End Function
Private Function parsenum(s As String)
Dim errorflag 'remeber if we hit any errors while decoding the string
errorflag = False
Dim i 'loop var
For i = 1 To Len(s)
Dim c 'step throuhg the string one char at a time and check to make sure all are in range
c = Mid(s, i, 1)
If ((c < "0" Or c > "9") And (c <> ".")) Then
errorflag = True
End If
Next i
If errorflag = True Then
parsenum = CVErr(xlErrNA)
Else
parsenum = Val(s)
End If
End Function
'Convert string to inches
'String in the format 12' 4 1/2"
Function s2i(s As String) As Double
' n = positive or negative
' f= number of feet
' i = number of whole inches
' ifract = fracitonal or decimal inches part
' Get rid of any leading or trailing spaces
s = Trim(s)
Dim n 'save sign of result
If (Len(s) > 0) And Left(s, 1) = "-" Then
n = -1
s = Trim(Mid(s, 2))
Else
n = 1
End If
Dim fp 'feet portion pointer
Dim f 'number of feet
fp = InStr(s, "'")
If (fp > 0) Then
f = parsenum(Left(s, fp - 1))
'f could be an error here - we'll deal with it later
s = Trim(Mid(s, fp + 1))
If (Left(s, 1) = "-") Then
s = Trim(Mid(s, 2))
End If
Else
f = 0
End If
Dim i 'whole number of inches
Dim ifract 'fractional inches
Dim inom 'nominator of fractuional inches
Dim idenom 'nominator of fractuional inches
Dim idec 'decimal portion of inches
If (Len(s) = 0) Then 'just feet, no inches...
i = 0
ifract = 0
Else
'the string must end with a " or it is an error
If Not Right(s, 1) = Chr(34) Then
i = CVErr(xlErrNA)
inom = 0
idenom = 0
idec = 0
Else
'get rid of the "
s = Left(s, Len(s) - 1)
'find space
Dim sp 'space pointer
sp = InStr(s, " ")
'next look for a fractional part
Dim bp 'fraction break pointer
bp = InStr(s, "/")
If bp = 0 And sp = 0 Then 'just a whole number inches? (no space or /)
i = parsenum(s)
ifract = 0
ElseIf bp > 0 And sp > 0 Then 'whole number with fraction?
'The space should never come after the /
If sp > bp Then
i = CVErr(xlErrNA)
ifract = CVErr(xlErrNA)
Else
'get the nom and denom
inom = parsenum(LTrim(Mid(s, sp + 1, bp - sp - 1)))
idenom = parsenum(Mid(s, bp + 1))
If idenom = 0 Then 'dont allow zero denominator
ifract = CVErr(xlErrNA)
Else
ifract = inom / idenom
End If
End If
i = parsenum(Trim(Left(s, sp)))
ElseIf sp = 0 And bp > 0 Then 'just fractional inches part with no whole number?
'get the nom and denom
i = 0
inom = parsenum(LTrim(Mid(s, 1, bp - 1)))
idenom = parsenum(Trim(Mid(s, bp + 1)))
If (idenom = 0) Then
ifract = CVErr(xlErrNA)
Else
ifract = inom / idenom
End If
Else 'fractional part was improperly formatted
i = CVErr(xlErrNA)
ifract = CVErr(xlErrNA)
End If
End If
End If
s2i = ((f * 12) + (i) + (ifract)) * n
End Function
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
MA non so come modificarlo per farlo funzionare.
( ho provato omettendo le righe che mi consigliava Elio ) .
E poi, basta incollarlo in < Sviluppo/Visual basic/visualizza codice > ??????
Grazie.
Si può vedere questo addin?
Magari caricalo su DropBox e metti qui il link al file.
Luca Lenzo
2018-07-06 17:38:20 UTC
Permalink
https://drive.google.com/file/d/0BwTobUSSKTCMV0VRa2hKYnFPSWtDcEliRkhIaUN6RTd4VUNr/view?usp=drivesdk

Spero funzioni

Grazie intanto
casanmaner
2018-07-06 17:57:02 UTC
Permalink
Post by Luca Lenzo
https://drive.google.com/file/d/0BwTobUSSKTCMV0VRa2hKYnFPSWtDcEliRkhIaUN6RTd4VUNr/view?usp=drivesdk
Spero funzioni
Grazie intanto
Ho visto.
Nell'Addin è presente un solo modulo standard con all'interno le funzioni che credo a te interessi utilizzare all'interno di un foglio (i2s e s2i).
Nel tuo file excel dove dove eseguire i calcoli, da salvare in formato xlsm, trascini il modulo presente nell'Addin nel progetto VBA della tua cartella di lavoro.
Per accedere all'editor VBA digita ALT+F11.
Per copiare il modulo dal xla al file xlsm selezioni il Module1 con il mouse e lo trascini nel progetto del file xlsm.
A quel punto in quella cartella di lavoro saranno disponibile sempre quelle FDU (funzioni definite dall'utente).
casanmaner
2018-07-06 18:00:26 UTC
Permalink
Post by casanmaner
Post by Luca Lenzo
https://drive.google.com/file/d/0BwTobUSSKTCMV0VRa2hKYnFPSWtDcEliRkhIaUN6RTd4VUNr/view?usp=drivesdk
Spero funzioni
Grazie intanto
Ho visto.
Nell'Addin è presente un solo modulo standard con all'interno le funzioni che credo a te interessi utilizzare all'interno di un foglio (i2s e s2i).
Nel tuo file excel dove dove eseguire i calcoli, da salvare in formato xlsm, trascini il modulo presente nell'Addin nel progetto VBA della tua cartella di lavoro.
Per accedere all'editor VBA digita ALT+F11.
Per copiare il modulo dal xla al file xlsm selezioni il Module1 con il mouse e lo trascini nel progetto del file xlsm.
A quel punto in quella cartella di lavoro saranno disponibile sempre quelle FDU (funzioni definite dall'utente).
Qui se vuoi un file xlsm dove ho copiato il codice presente nel module1 del xla e ho copiato le formule che erano presente in sheet1 sempre del xla.

La cartella di lavoro è impostata per visualizzare le formule e non i risultati (Ctrl+Maisc+8 per ripristinare la visualizzazione dei risultati delle formule).

https://www.dropbox.com/s/nndufxexxgrjlk1/InchCalc.xlsm?dl=0

ciao
n***@gmail.com
2018-07-09 06:54:51 UTC
Permalink
Post by casanmaner
Post by casanmaner
Post by Luca Lenzo
https://drive.google.com/file/d/0BwTobUSSKTCMV0VRa2hKYnFPSWtDcEliRkhIaUN6RTd4VUNr/view?usp=drivesdk
Spero funzioni
Grazie intanto
Ho visto.
Nell'Addin è presente un solo modulo standard con all'interno le funzioni che credo a te interessi utilizzare all'interno di un foglio (i2s e s2i).
Nel tuo file excel dove dove eseguire i calcoli, da salvare in formato xlsm, trascini il modulo presente nell'Addin nel progetto VBA della tua cartella di lavoro.
Per accedere all'editor VBA digita ALT+F11.
Per copiare il modulo dal xla al file xlsm selezioni il Module1 con il mouse e lo trascini nel progetto del file xlsm.
A quel punto in quella cartella di lavoro saranno disponibile sempre quelle FDU (funzioni definite dall'utente).
Qui se vuoi un file xlsm dove ho copiato il codice presente nel module1 del xla e ho copiato le formule che erano presente in sheet1 sempre del xla.
La cartella di lavoro è impostata per visualizzare le formule e non i risultati (Ctrl+Maisc+8 per ripristinare la visualizzazione dei risultati delle formule).
https://www.dropbox.com/s/nndufxexxgrjlk1/InchCalc.xlsm?dl=0
ciao
TOOOOOOOOOOOpppppppppppppppp funziona. Grazie ragazzi , come sempre riesco a risolvere con voi. Avanzate una birra, un bit-coin , uhm.... vabbè dai , però vi auguro buone vacanze a voi e famiglia........... :-)
Continua a leggere su narkive:
Loading...