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

Hi All,

Do somebody know a simple user function converting calulated resisto
value to nearest E12 standard one.

Thaks in advance:confused

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default E12 conversion

Thanks Guys

After very useful help advices I realize I have to do it myself.
Former Basic user, never build any code this is wath I have done.
Enjoy.


Function CnvSt(InVal As Double)
' My DIY function converting any calculated value capacitor
' or resistor to standard E12 row value

Dim A As Variant, Ras, K, CntM, CntD
Ras = 10000000000#: ContM = 0: CountD = 0
A = Array(1, 1.2, 1.5, 1.8 , 2.2, 2.7, 3.3, 4.7, 5.6, 6.8, 8.2)
InValM = InVal:

'for numbers over 10
If InVal 10 Then
Do While InValM 10
InValM = InValM / 10
CntM = CntM + 1
Loop
End If

' for numbers below 1
If InVal < 1 Then
Do While InValM < 1
InValM = InValM * 10
CntD = CntD + 1
Loop
End If

For j = 0 To 10
If Abs(InValM - A(j)) < Ras Then
Ras = Abs(InValM - A(j))
K = j
End If
Next j
OpVal = A(K) * 10 ^ (CntM) * 10 ^ ((-1) * CntD)
CnvSt = OpVal

End Functio

--
Message posted from http://www.ExcelForum.com

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
Conversion help Iriemon Excel Worksheet Functions 1 April 1st 09 03:57 PM
Day Conversion Michael Excel Worksheet Functions 3 September 10th 07 11:40 PM
Between conversion Dan Wilson Excel Worksheet Functions 0 March 13th 05 03:02 PM
Conversion SVC Excel Worksheet Functions 9 February 28th 05 02:29 PM
XML Conversion GeneO Excel Programming 2 February 26th 04 02:59 PM


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