Jack in the UK
Well-known Member
- Joined
- Feb 16, 2002
- Messages
- 3,215
I posted this, thought was good post, but left large spaces between lines>>>
I wrote the code, im learning = this is as is,?? Any ideas??
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>The other way you might wish to UDF is via VBA</title>
<style>
<!--
p.MsoNormal
{mso-style-parent:"";
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";
margin-left:0in; margin-right:0in; margin-top:0in}
-->
</style>
</head>
<body>
<p class="MsoNormal"><span style="font-family: Arial">The other way you might
wish to UDF is via VBA, this is a script I wrote to add a A in from of any cell
value less than 10000 i.e. 9999 to 0 will be A999 or A0001</span></p>
<p class="MsoNormal"><span style="font-family: Arial">The function you need is
related to the range but try</span></p>
<p class="MsoNormal">
<span style="font-family: Script; text-decoration: overline underline blink">
<font color="#0000FF" size="3">=JackintheUK_ConvA(A1)</font></span></p>
<p class="MsoNormal">
<span style="font-family: Arial; text-decoration: underline; font-weight: 700">
Put this in VBA by:</span></p>
<p class="MsoNormal"><span style="font-family: Arial">In Excel as normal = Press
together the Alt+F11 keys and let go, you will see a new kind of program appear
this is the Visual Basic for Application Editor (VBE)</span></p>
<p class="MsoNormal"><span style="font-family: Arial">There will be little in
the Project = Project VBA window pane.</span></p>
<p class="MsoNormal"><span style="font-family: Arial">Look for the name of your
sheets, (will say VBA Project (your workbooks name) helps of only on book open
till you get used to its, it like windows explorer you soon see it, but name as
normal</span></p>
<p class="MsoNormal"><span style="font-family: Arial">Select this WkBk *VBA
Project (your workbooks name)* and there will be nothing in it.</span></p>
<p class="MsoNormal"><span style="font-family: Arial">Just below you see a name
bit called Microsoft Excel Objects</span></p>
<p class="MsoNormal"><span style="font-family: Arial">Now right click it
on the name part. </span></p>
<p class="MsoNormal"><span style="font-family: Arial">A pop up appears.</span></p>
<p class="MsoNormal"><span style="font-family: Arial">Choose</span><font color="#FF00FF"><span style="font-family: Arial; text-decoration: blink">
INSERT</span></font></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">And select module, </span>
</font></span></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">A bit of flick and
clicking and you see a new line has appeared, called</span></font></span></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">MODULES / MODULE 1</span></font></span></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">Click on this and paste
in my code I have provided.</span></font></span></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">Don't forget in cells</span></font></span></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">A1 type 666 </span>
</font></span></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">A2 type 10004</span></font></span></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">In B1 type = </span>
</font></span>
<span style="font-family: Script; text-decoration: overline underline blink">
<font color="#0000FF" size="3">=JackintheUK_ConvA(A1) and drag down one.</font></span></p>
<p class="MsoNormal"><span style="font-weight: 400">
<font color="#0000FF" size="3"><span style="font-family: Arial">The results will
be A0666 and 10004</span></font></span><span style="font-family: Arial; color: blue">
</span>Function JackintheUK_ConvA(MyRange As Range) As String
Application.Volatile
MyFormat = ("A0000")
If MyRange < 10000 Then
JackintheUK_ConvA = Format(MyRange.Value, MyFormat)
Else
JackintheUK_ConvA = MyRange.Value
End If
Calculate
End Function
Formula needed on Jacks UDF</p>
<p class="MsoNormal"><span style="font-weight: 400; font-family: Arial">
<font color="#0000FF" size="3">=JackintheUK_ConvA(A1)</font></span></p>
</body>
</html>
I wrote the code, im learning = this is as is,?? Any ideas??
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>The other way you might wish to UDF is via VBA</title>
<style>
<!--
p.MsoNormal
{mso-style-parent:"";
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";
margin-left:0in; margin-right:0in; margin-top:0in}
-->
</style>
</head>
<body>
<p class="MsoNormal"><span style="font-family: Arial">The other way you might
wish to UDF is via VBA, this is a script I wrote to add a A in from of any cell
value less than 10000 i.e. 9999 to 0 will be A999 or A0001</span></p>
<p class="MsoNormal"><span style="font-family: Arial">The function you need is
related to the range but try</span></p>
<p class="MsoNormal">
<span style="font-family: Script; text-decoration: overline underline blink">
<font color="#0000FF" size="3">=JackintheUK_ConvA(A1)</font></span></p>
<p class="MsoNormal">
<span style="font-family: Arial; text-decoration: underline; font-weight: 700">
Put this in VBA by:</span></p>
<p class="MsoNormal"><span style="font-family: Arial">In Excel as normal = Press
together the Alt+F11 keys and let go, you will see a new kind of program appear
this is the Visual Basic for Application Editor (VBE)</span></p>
<p class="MsoNormal"><span style="font-family: Arial">There will be little in
the Project = Project VBA window pane.</span></p>
<p class="MsoNormal"><span style="font-family: Arial">Look for the name of your
sheets, (will say VBA Project (your workbooks name) helps of only on book open
till you get used to its, it like windows explorer you soon see it, but name as
normal</span></p>
<p class="MsoNormal"><span style="font-family: Arial">Select this WkBk *VBA
Project (your workbooks name)* and there will be nothing in it.</span></p>
<p class="MsoNormal"><span style="font-family: Arial">Just below you see a name
bit called Microsoft Excel Objects</span></p>
<p class="MsoNormal"><span style="font-family: Arial">Now right click it
on the name part. </span></p>
<p class="MsoNormal"><span style="font-family: Arial">A pop up appears.</span></p>
<p class="MsoNormal"><span style="font-family: Arial">Choose</span><font color="#FF00FF"><span style="font-family: Arial; text-decoration: blink">
INSERT</span></font></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">And select module, </span>
</font></span></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">A bit of flick and
clicking and you see a new line has appeared, called</span></font></span></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">MODULES / MODULE 1</span></font></span></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">Click on this and paste
in my code I have provided.</span></font></span></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">Don't forget in cells</span></font></span></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">A1 type 666 </span>
</font></span></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">A2 type 10004</span></font></span></p>
<p class="MsoNormal"><span style="text-decoration: blink">
<font color="#FF00FF"><span style="font-family: Arial">In B1 type = </span>
</font></span>
<span style="font-family: Script; text-decoration: overline underline blink">
<font color="#0000FF" size="3">=JackintheUK_ConvA(A1) and drag down one.</font></span></p>
<p class="MsoNormal"><span style="font-weight: 400">
<font color="#0000FF" size="3"><span style="font-family: Arial">The results will
be A0666 and 10004</span></font></span><span style="font-family: Arial; color: blue">
</span>Function JackintheUK_ConvA(MyRange As Range) As String
Application.Volatile
MyFormat = ("A0000")
If MyRange < 10000 Then
JackintheUK_ConvA = Format(MyRange.Value, MyFormat)
Else
JackintheUK_ConvA = MyRange.Value
End If
Calculate
End Function
Formula needed on Jacks UDF</p>
<p class="MsoNormal"><span style="font-weight: 400; font-family: Arial">
<font color="#0000FF" size="3">=JackintheUK_ConvA(A1)</font></span></p>
</body>
</html>