tag:blogger.com,1999:blog-13255958748480843392024-02-20T03:27:05.584-08:00Excel, Visual Basic for Applications(VBA), C, Oracle & Technology 2 Core.This blog is about Technology. One ultimate destination for tutorials on programming languages, exploring about complex situations in different programming languages.
Also Knowing about most wanted technologies now and in Future. The Major content as of now will be focussed on Excel and Visual Basic for Applications(VBA). Have a happy reading...!!Ravindra Singh Yadavhttp://www.blogger.com/profile/08163533106249419574noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-1325595874848084339.post-721603249765250792010-01-05T19:28:00.000-08:002010-01-05T20:28:42.203-08:00Writing a Sweet VBA Code Post 8.0Hi Everyone!<br /><br />There are different ways of writing a same piece code which performs same task as the other. But one piece of code can make your and subsequent developers a cake walk while the other can make it really tough.<br /><br />So not always the code which you write has the objective to just perform the function.Ravindra Singh Yadavhttp://www.blogger.com/profile/08163533106249419574noreply@blogger.com1tag:blogger.com,1999:blog-1325595874848084339.post-52346152678772048952010-01-04T20:17:00.001-08:002010-01-04T20:28:52.698-08:00Error Handler in VBA 7.0<span style="color: #274e13;">Handling Error in form of programing language is vital task. To protect your application from stoping/freezing in midway is important. If you handle the error properly then you will not only successfully execute the application but you can also make user aware of the error which was thrown during the execution.</span><br /><span style="color: #274e13;"><br /></span><br /><span style="color: #274e13;">Lets us take a simple example for error handler:</span><br /><span style="color: #274e13;"><br /></span><br /><span style="color: #274e13;"></span><br /><span style="color: #274e13;">Sub prTest()<br />'Error Handler Starts<br />On Error GoTo Err_PrTest:<br />Dim rngTest As Range<br />Dim intTest As Integer<br />Dim intCounter As Integer<br /><br />If rngTest(1, 1) = 0 Then<br /> 'Do Nothing<br /> End If<br /><br /><br />Exit_PrTest:<br /> Set rngTest = Nothing<br /> Exit Sub<br />Err_PrTest:<br /> MsgBox Err.Description<br /> GoTo Exit_PrTest<br />End Sub<br /></span><br /><br />Once this code goes into error below error is thrown to the user:Ravindra Singh Yadavhttp://www.blogger.com/profile/08163533106249419574noreply@blogger.com0tag:blogger.com,1999:blog-1325595874848084339.post-36577958739187379132009-12-25T20:43:00.000-08:002009-12-30T15:06:24.124-08:00Optimized FOR Loop in VBA:6.0<span style="color: #274e13;">Hi Everyone!</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="color: #274e13;">Writting a For loop in vba is not a big deal but one common mistake which lot of developers tend to do. They tend to write the for as below:</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="text-decoration: underline;"><span style="color: #274e13;">InEfficient Method:</span></span><br />
<span style="color: #274e13;"></span><br />
<span style="color: #741b47;">Sub prTest()</span><br />
<span style="color: #741b47;"><br />
</span> <br />
<span style="color: #741b47;">'Error Handler</span><br />
<span style="color: #741b47;">On Error GoTo Err_PrTest:</span><br />
<span style="color: magenta;"><br />
</span> <br />
<span style="color: purple;">Dim intStartCounter As Integer</span><br />
<span style="color: purple;">Dim intLoopCounter As Integer</span><br />
<span style="color: purple;">Dim rngTest As Range</span><br />
<span style="color: purple;"><br />
</span> <br />
<span style="color: purple;">intLoopCounter = 5</span><br />
<span style="color: purple;">Set rngTest = Range("Test")</span><br />
<span style="color: purple;"><br />
</span> <br />
<span style="color: purple;">For intStartCounter = 1 To intLoopCounter</span><br />
<span style="color: purple;"> If rngTest(intStartCounter, 1) = "Test" Then</span><br />
<span style="color: purple;"> 'Do Nothing</span><br />
<span style="color: purple;"> End If</span><br />
<span style="color: purple;">Next intStartCounter</span><br />
<span style="color: purple;"><br />
</span> <br />
<span style="color: purple;">Exit_PrTest:</span><br />
<span style="color: purple;"> Exit Sub</span><br />
<span style="color: purple;">Err_PrTest:</span><br />
<span style="color: purple;"> GoTo Exit_PrTest</span><br />
<span style="color: purple;">End Sub</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="text-decoration: underline;"><span style="color: #274e13;">2)Efficient Method</span></span><br />
<span style="color: purple;"><br />
</span> <br />
<span style="color: purple;">Sub prTest()</span><br />
<span style="color: purple;"><br />
</span> <br />
<span style="color: purple;">'Error Handler</span><br />
<span style="color: purple;">On Error GoTo Err_PrTest:</span><br />
<span style="color: purple;"><br />
</span> <br />
<span style="color: purple;">Dim intStartCounter As Integer</span><br />
<span style="color: purple;">Dim intLoopCounter As Integer</span><br />
<span style="color: purple;">Dim rngTest As Range</span><br />
<span style="color: purple;"><br />
</span> <br />
<span style="color: purple;">intLoopCounter = 5</span><br />
<span style="color: purple;">Set rngTest = Range("Test")</span><br />
<span style="color: purple;"><br />
</span> <br />
<span style="color: purple;">For intStartCounter = 1 To intLoopCounter</span><br />
<span style="color: purple;"> If rngTest(intStartCounter, 1) = "Test" Then</span><br />
<span style="color: purple;"> 'Exit the for loop as soon as you find the Test. Other as soon as the purpose of for loop</span><br />
<span style="color: purple;"> 'is satisfied exit</span><br />
<span style="color: purple;"> Exit For</span><br />
<span style="color: purple;"> End If</span><br />
<span style="color: purple;">Next intStartCounter</span><br />
<span style="color: purple;"><br />
</span> <br />
<span style="color: purple;">Exit_PrTest:</span><br />
<span style="color: purple;"> Exit Sub</span><br />
<span style="color: purple;">Err_PrTest:</span><br />
<span style="color: purple;"> GoTo Exit_PrTest</span><br />
<span style="color: purple;">End Sub</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="color: #274e13;">The difference between 1 & 2 is that in case of 2 you exit the for loop once the purpose of FOR loop is satisfied and therefore you save execution time. 2 will make code more optimized.</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="color: #274e13;">Cheers!</span>Ravindra Singh Yadavhttp://www.blogger.com/profile/08163533106249419574noreply@blogger.com0tag:blogger.com,1999:blog-1325595874848084339.post-19472063135116700902009-11-24T16:08:00.000-08:002009-11-24T16:08:13.613-08:00Excel/MDB 5.0<span style="color: #274e13;">Do you know ?</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="color: #274e13;">I am not sure if you have noticed this with some of Excel older versions for Eg: 2003. When you have a mdb which has more than 65,536 rows lets say 65,537, now when you try to pull in these mdb records into Excel? What happens then. You will notice that there will not be any error message flashed by Excel. So it hard to catch it, but the cause is pretty simple. We are trying pull in more rows than the capacity of Excel which is not possible.</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="color: #274e13;">This limitation of Excel 2003 is not present in Excel2007.</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="color: #274e13;">Cheers!!</span>Ravindra Singh Yadavhttp://www.blogger.com/profile/08163533106249419574noreply@blogger.com3tag:blogger.com,1999:blog-1325595874848084339.post-69081519592578381532009-11-15T20:24:00.000-08:002009-11-15T20:24:27.637-08:00Excel declaring same range twice in the Worksheet Post 4.0<span style="color: #274e13;">Today I would be sharing about a small & simple thing. But this is indeed an important thing and might lead to trouble in case you are not aware of it!!</span><br />
<span style="color: #274e13;">This limitation is with Excel 2003 and some lower versions of excel. Try declaring some range name Test in Sheet1!A1.</span><br />
<span style="color: #274e13;">Now again go to Sheet2!A1 and give again same range name in this cell. Excel quietly gives this name to this cell without popping any Error message(That range name already exists). So in this process what happens is that the range name Test which was there in Sheet1!A1 is deleted implicitly. </span><br />
<span style="color: #274e13;"><br />
</span><br />
<span class="Apple-style-span" style="text-decoration: underline;"><span style="color: #274e13;">Impact</span></span><span style="color: #274e13;">:As a result of this wherever you were using Test (Sheet!A1) now will start using Sheet2!A1 so that calculation will start going wrong in the worksheet/Workbook.</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span class="Apple-style-span" style="text-decoration: underline;"><span style="color: #274e13;">Solution:</span></span><span style="color: #274e13;"> To avoid this Issue whenever you declare any new range just check for the range name if already exists. To check this you can go to keyboard Ctrl+G and enter the new range name to see if it exits.</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="color: #274e13;">Now one good thing is that Excel higher versions like Windows Vista does not have this Issue and Excel throws a warning message explicitly.</span>Ravindra Singh Yadavhttp://www.blogger.com/profile/08163533106249419574noreply@blogger.com0tag:blogger.com,1999:blog-1325595874848084339.post-43264489817460289262009-11-01T18:26:00.000-08:002009-11-01T18:30:45.127-08:00Connect to DataBase from VBA/Excel Post 3.0<span style="color: #274e13;">Through VBA we can connect Microsoft Database(MDB) and can access the data from tables in the MDB. This data can be populated in the Excel sheet from these tables.</span><br />
<span style="color: #274e13;">I have already explained some of the basics regarding VBA in my earlier posts. So today we will see how we can connect to MDB through VBA.</span><br />
<span style="color: #274e13;">Below is the code which can be used to pull data from MDB and populate in Excel:</span><br />
<span style="color: #274e13;">Before moving the actual code we should understand what is .accdb file. The accdb file format was introduced with release of Microsoft Access 2007 to replace the older MDB file format. So when we use ACCDB format allow users to leverage enhanced fucntionality in access ,including the use of multivalued fields and strong cryptography.</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="color: #274e13;">Sub prConnecttoMDB()</span><br />
<span style="color: #274e13;">On Error GoTo Err_prConnecttoMDB</span><br />
<span style="color: #274e13;">Dim strConnection As String</span><br />
<span style="color: #274e13;">Dim strSQl As String</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="color: #274e13;">strConnection = "ODBC; DSN=MS Access Database;DBQ=D:\LearnVBA\Test_01.accdb; Driver={Driver do Microsoft Access (*.accdb)}"</span><br />
<span style="color: #274e13;">strSQl = "SELECT TestTable.SerialNo, TestTable.MemberName, TestTable.School,TestTable.NativePlace,TestTable.Income FROM TestTable"</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="color: #274e13;">With ActiveSheet.QueryTables.Add(Connection:=strConnection, Destination:=ActiveSheet.Range("Test"))</span><br />
<span style="color: #274e13;"> .CommandText = strSQl</span><br />
<span style="color: #274e13;"> .Name = "TestTable"</span><br />
<span style="color: #274e13;"> .Refresh BackgroundQuery:=False</span><br />
<span style="color: #274e13;">End With</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="color: #274e13;">Exit_prConnecttoMDB:</span><br />
<span style="color: #274e13;"> Exit Sub</span><br />
<span style="color: #274e13;"><br />
</span><br />
<span style="color: #274e13;">Err_prConnecttoMDB:</span><br />
<span style="color: #274e13;"> GoTo Exit_prConnecttoMDB</span><br />
<span style="color: #274e13;">End Sub</span><br />
<div><span style="color: #274e13;"><br />
</span><br />
</div><div><span style="color: #274e13;">The below code pulls the data from the MDB file placed at D:\LearnVBA\Test_01.accdb to Excel active sheet in range Test.</span><br />
</div><div><br />
</div>Ravindra Singh Yadavhttp://www.blogger.com/profile/08163533106249419574noreply@blogger.com0tag:blogger.com,1999:blog-1325595874848084339.post-21904171842770247152009-10-27T18:16:00.000-07:002009-11-01T18:31:29.610-08:00Variables in VBA Post 2.0<span style="text-decoration: underline;"><span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">Variables in VBA:</span></span></span></span><br />
<span style="text-decoration: underline;"><span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;"><br />
</span> </span><span style="color: #274e13;"> </span></span><span style="background-color: white;"><span style="color: #274e13;"> </span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">1)Variables in VBA are declared by using Dim statement. VBA like any other programing language as many variable types. To list a few Integer,Double,String,Long,Variant,Range etc.</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">If a string variable needs to be declared it can be declared as</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;"><br />
</span> </span><span style="color: #274e13;"> </span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">Dim strTest as String</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;"><br />
</span> </span><span style="color: #274e13;"> </span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">The above style of declaring the variable is called Hungarian notation. In this variable name is prefixed by the variable type. Another variable is Range which is different from other programming languages. Range variable is declared similar to any other variable like Dim rngTest as Range. Any range in excel can be used in VBA by setting that range to this range variable. To play with this range first set this range as :</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">Set rngTest=Range("A1:B3")</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">Now the range variable rngTest can be used to access the variables in this range.</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">rngTest(1,1)->This will give you the value in cell A1.</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;"><br />
</span> </span><span style="color: #274e13;"> </span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">2)Variant is one powerful variable in VBA. It can hold different variable types. So Variant is used when the user is not sure about the variable type. Do not try to use variant as the preferred variable. It might seem to be easy and obvious choice but it can be dangerous considering the code performance.</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">If you use Variant as data type the compiler will take more time in identifying the Variable as compared to a variable of specific type.</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">If you are using Variant as variable type for variable which stores always one integer value. Then there is one is disadvantage that you might not be able to see the value of the variable while debugging. There might also Issue where lot of "type mismatch" errors will be missed if you use Variant as datatype.</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;"><br />
</span> </span><span style="color: #274e13;"> </span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">An array variable can be declared as variant type.</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">Dim arrTest as variant.</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;"><br />
</span> </span><span style="color: #274e13;"> </span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">The lower bound of this array is 0. To change the upper the bound of this array it can be redeemed.</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">Redim arrTest(1,4)</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;"><br />
</span> </span><span style="color: #274e13;"> </span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">Now keep in mind one thing that lower bound always starts with 0. In case you have to change the lower bound you can</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">Option base 2</span></span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="background-color: white;"><span style="color: #274e13;">This will take the lower bound as 2. By default the lower bound is 2.</span></span></span>Ravindra Singh Yadavhttp://www.blogger.com/profile/08163533106249419574noreply@blogger.com0tag:blogger.com,1999:blog-1325595874848084339.post-45438562203465869472009-10-25T12:36:00.000-07:002009-10-27T19:27:08.136-07:00Excel Worksheet Post 1.0<span style="font-family: 'Trebuchet MS', sans-serif;"><span style="color: #274e13;">Some of us know Excel for doing some simple calculations. These simple calculations can be adding ,subtracting set of values in Excel cells. But Excel actually is powerful platform for solving complex calculations and presenting results. We can go even a step further and make Excel even more Powerful. We can program Excel with VBA & .Net.</span></span><br />
<div><span style="font-size: small;"><span style="font-size: 13px;"><span style="font-family: 'Trebuchet MS', sans-serif;"><span style="color: #274e13;"><br />
</span> </span><span style="color: #274e13;"> </span></span></span><br />
<span style="font-family: 'Trebuchet MS', sans-serif;"><span style="color: #274e13;">1)When do we see limitation of Excel:What if we have huge data in Excel and we need to apply several formula's to arrive at final result. To handle this alone in Excel will be next to impossible. We can take help of VBA for same. At the back of Excel we can use VBA programming language to code several procedures and functions. These procedures and functions can make use of Excel formula's internally in the looping structures and perform complex calculations. These results can again be populated back on the Excel surface. The input required for calculations in VBA can taken from the Excel surface. The Inputs can be played by user on the Excel surface.</span></span><br />
<span style="font-family: 'Trebuchet MS', sans-serif;"><span style="color: #274e13;"><br />
</span> </span><br />
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span style="font-family: 'Trebuchet MS', sans-serif;"><span style="color: #274e13;">2)When you write a formula in Excel and you try to use so many Excel functions in the formula, at one point you will see that formula will start throwing error. From the error it will appear to you that formula is wrong but it is not the case actually. So in this you will have to break the formula into two part. Put one part of formula in different cell (Intermediate cell). Now you can refer this cell in the main formula. Your formula is all set now.</span></span><br />
</div><br />
</div>Ravindra Singh Yadavhttp://www.blogger.com/profile/08163533106249419574noreply@blogger.com0tag:blogger.com,1999:blog-1325595874848084339.post-63697825271125049502009-10-24T11:14:00.000-07:002009-11-01T18:32:21.267-08:00Basics of VBA/What is VBA Post 1.0<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">Unlike Visual Basic not many people know about Visual Basic for applications(VBA). Excel has so many features but do you know that you can even add to these features by going behind Excel. To start programming you need a VBA editor. You can arrive at editor by pressing ALT+F11 from key board. Once you press this you will see similar kind of interface as Visual Basic. You will see the VBA project similar to VB. In this project you will have Tool box similar to VB. You can add a Form and can embed different tools such as Text box, radio button etc. You can also insert Module and Class.</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">VBA is flexible and you can write various functions, procedures. You can declare variables like integer,double etc like in any other programming language. I will restrict this post to basic and will take up more as we move further.</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">Let us try to write a simple Hello World program in VBA.</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">Once you press ALT+F11 you are in VBA editor.</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">1)Go to 'Insert->Module' on menu bar.</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">2)Click on the Module1 which is on left side of the page.</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">3)Go to Tools->Options->Editor->Check the check box 'Require Variable Declaration. To explain why is this required. This is not one of mandatory step, even if you do not check this the code will work fine. This step though provides you an additional feature. If you try to use a variable in a procedure without declaring a variable, code will throw compile error. So you know that you need to declare a variable before using it. In short this helps you to find a defect in code.</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">4)See program below:</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;"><br />
</span> </span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">Sub test()</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">Dim strHelloWorld As String</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;"><br />
</span> </span><span style="color: #274e13;"> </span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">strHelloWorld = "Hello World"</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">MsgBox strHelloWorld</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;"><br />
</span> </span><span style="color: #274e13;"> </span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">End Sub</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;"><br />
</span> </span><span style="color: #274e13;"> </span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">5)In the above program strHelloWorld is a string variable which holds the string variable.</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">Sub stands for procedure. Msgbox will output the string hello world.</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">6)Compile the code by going to Menu bar Debug->Compile VBA Project. Ensure that code should not throw any error.</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">7)O/P:Go to Menu Bar Run->Run Sub/UserForm. This pops up form saying Macro. Select the Macro which you want to run. Here you need select sub Test and click on Run.</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">It displays the output as HelloWorld.</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;"><br />
</span> </span><span style="color: #274e13;"> </span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">Summary</span></span><br />
<span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: #274e13;">The above was a simple way to explain about first program in VBA. If anyone has any comment or additional input please go ahead and post comment or initiate discussion.</span></span>Ravindra Singh Yadavhttp://www.blogger.com/profile/08163533106249419574noreply@blogger.com0